Hello everyone,
I am trying my best to finish project of gamepad with gyroscope (MPU-9050), on my Arduino Leonardo.
I have no problem to read and use potentiometers and buttons, but I can not find out how to convert signals from SDA and SCL.
When I use example code below I can see datas in serial monitor:
#include <MPU6050_tockn.h>
#include <Wire.h>
MPU6050 mpu6050(Wire);
void setup() {
Serial.begin(9600);
Wire.begin();
mpu6050.begin();
mpu6050.calcGyroOffsets(true);
}
void loop() {
mpu6050.update();
Serial.print("angleX : ");
Serial.print(mpu6050.getAngleX());
Serial.print("\tangleY : ");
Serial.print(mpu6050.getAngleY());
Serial.print("\tangleZ : ");
Serial.println(mpu6050.getAngleZ());
}
But what is the correct way to convert them and use as xAxis in my code?
Example of my code below, how to exchange "analogRead(A2)" for data from gyrocope from example above?
#include <Joystick.h>
#include <arduino.h>
Joystick_ Joystick;
int xAxis_ = 0;
const bool initAutoSendState = true;
void loop() {
//LEFT - RIGHT
xAxis_ = analogRead(A2);
xAxis_ = map(xAxis_,0,1023,0,1023);
Joystick.setXAxis(xAxis_);
delay (50);
}
I will be glad for every help.
Thank you in advance.