I2Cdevlib Forums  # Piyumal

Members

3

• #### Days Won

3

Piyumal had the most liked content!

## Piyumal's Achievements 1

### Reputation

1. Hello friends, I am trying to make a self balancing robot, so I found some tutorials regarding Complementary filters. In that tutorial there is a equation for take acceleration and gyro value, these are the equation, x_acc = (x_acc_ADC - x_acc_offset) * x_acc_scale; gyro = (gyro_ADC - gyro_offset) * gyro_scale; form that I obtained following values, ax= 0 gy= -159 x_acc= 148.00 gyro= 11000.00 ax= -116 gy= -184 x_acc= -84.00 gyro= -1500.00 ax= -40 gy= -175 x_acc= 68.00 gyro= 3000.00 ax= -48 gy= -177 x_acc= 52.00 gyro= 2000.00 ax= 4 gy= -183 x_acc= 156.00 gyro= -1000.00 ax= -60 gy= -190 x_acc= 28.00 gyro= -4500.00 ax= -84 gy= -192 x_acc= -20.00 gyro= -5500.00 ax= -92 gy= -184 x_acc= -36.00 gyro= -1500.00 ax= -88 gy= -164 x_acc= -28.00 gyro= 8500.00 Here is my code, #include <Wire.h> #include <I2Cdev.h> #include <MPU6050.h> MPU6050 mpu; int16_t ax, ay, az; int16_t gx, gy, gz; float x_acc, gyro; void setup() { // put your setup code here, to run once: Serial.begin(1200); Serial.println("Initialize MPU"); mpu.initialize(); } void loop(){ mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); Serial.print("ax= "); Serial.print(ax); Serial.print("\t\t"); Serial.print("gy= "); Serial.print(gy); Serial.print("\t\t"); x_acc= (ax - (-74))*(2); Serial.print("x_acc= "); Serial.print(x_acc); Serial.print("\t\t"); gyro= (gy - (-181))*(500); Serial.print("gyro= "); Serial.print(gyro); Serial.print("\n"); } Please let me know whether that values are correct or not, if it is not please help me to correct it.. Thank you!
2. am trying to make gesture control car for my university mini project. I am using MPU6050 and nRF24l01, separately both are working, but I can't combine both and i can't control a motor according to the motion of MPU6050. please your help is highly appreciated. (i am new to Arduino).. thank you. i have used MPU6050 and Mirf libraries..
×