передача значений по уарт(радиомодули) HC12
- Войдите на сайт для отправки комментариев
Вс, 21/05/2017 - 11:11
Нужно передать значения х у по уарт, мне обьяснили, но я глуп и не понял что то
#include <SoftwareSerial.h> /* Code to view on the Serial Monitor the values of the Gyroscope * and the output for the mouse. This is equal to the standard code * but with instructions to check the values on the Serial monitor. * Change the delay to read the values at reduced speed. * * Gabry295 */ #include <Wire.h> #include <I2Cdev.h> #include <MPU6050.h> #include <Mouse.h> MPU6050 mpu; int16_t ax, ay, az, gx, gy, gz; int vx, vy; void setup() { Serial.begin(9600); Wire.begin(); mpu.initialize(); if (!mpu.testConnection()) { while (1); } } void loop() { mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); vx = (gx+300)/150; // "+300" because the x axis of gyroscope give values about -350 while it's not moving. Change this value if you get something different using the TEST code, chacking if there are values far from zero. vy = -(gz-100)/150; // same here about "-100" Serial.print("vx = "); Serial.print(gx); Serial.print(" | gz = "); Serial.print(gz); Serial.print(" | X = "); Serial.print(vx); Serial.print(" | Y = "); Serial.println(vy); delay(20); }
У меня один контроллер NAMO другой Leonardo
я передаю с Нано на леонардо
Мне обьяснили что
sprint(str, "что то написать %d, var);
отправка " * vx # vy"
Serialprint
на леонардо
Принимаем строку
if (" * ") вытаскиваем VX
v1
v2
v3
VX=v1*100+v2*10+v3
vy
я тут много не до понял
Помогите