RE-Edited!
Hello! i have a code working for accelerometer air mouse with transmisor and receptor with tilt X and Y tilting up or down its okei but i want to change y for z coz i dont wanna tilt on Y only rotate with z, basicly i need to use pitch and yaw not roll
i try to do this:
Any help?
Thank you!!
maybe i need to implement some gyro code?
Receptor
long x;
long y;
#include "Keyboard.h"
#include "Mouse.h"
#include <SoftwareSerial.h>
// software serial//Software Serial Port
SoftwareSerial HC05_Serial(9, 10); // RX, TX
long serialA;
void setup() { // initialize the buttons' inputs:
 Serial.begin(38400);
 HC05_Serial.begin(38400);
 Mouse.begin();
 Keyboard.begin();
 delay(1000);
 Serial.println("Initialization Done!");
}
void loop() {
   Â
   if (HC05_Serial.available() > 2) {
 serialA = HC05_Serial.parseInt();
 Serial.println(serialA);
 }Â
  if (serialA>= 19997 && serialA <20008){
 Â
  Serial.println("xread");
  Serial.println(x);
 Â
x=map(serialA,19997,20008,-4,4);
  delay(10);
  }
 Â
  if (serialA>= 29997 && serialA <30008){
 Â
  Serial.println("yread");
 Serial.println(y);
 y=map(serialA,29997,30008,-4,4);
Â
  delay(10);
  }Â
Mouse.move(x, y);
  Â
}
Transmisor
#include <Wire.h>
#include <I2Cdev.h>
#include <MPU6050.h>
MPU6050 mpu;
int16_t ax, ay, az;
int16_t gx, gy, gz;
void setup() {
 Serial2.begin(38400);
 Wire.begin();
Â
 mpu.initialize();
}
void loop() {
 mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
long x=map(ax,-17000,17000,19997,20008);
long y=map(ay,-17000,17000,29997,30008);
Serial2.println(x);
delay(10);
Serial2.println(y);
delay(10);
}