Hi i m a beginner
making a gesture display for car safety its my university project i m using accelerometer #Imu sensor #MPU-6050 but the code i ve used is not fine can any one guide me with this please below is the code;
// MPU-6050 Short Example Sketch
// By Arduino User JohnChi
// August 17, 2014
// Public Domain
#include<Wire.h>
const int MPU_addr=0x68; // I2C address of the /MPU6050
float AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
float target;
void setup(){
Wire.begin();
Wire.beginTransmission(MPU_addr);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);
pinMode(13,OUTPUT);
Serial.begin(9600);
}
void loop(){
target =AcY;
Wire.beginTransmission(MPU_addr);
Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H)
Wire.endTransmission(false);
Wire.requestFrom(MPU_addr,14,true); // request a total of 14 registers
AcX=Wire.read()<<8|Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
AcY=Wire.read()<<8|Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
AcZ=Wire.read()<<8|Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
Tmp=Wire.read()<<8|Wire.read(); // 0x41 (TEMP_OUT_H) & 0x42 (TEMP_OUT_L)
GyX=Wire.read()<<8|Wire.read(); // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
GyY=Wire.read()<<8|Wire.read(); // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
GyZ=Wire.read()<<8|Wire.read(); // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
//Serial.print("AcX = "); Serial.print(AcX/1000);
// Serial.print(" | AcY = "); Serial.print(AcY/1000);
//Serial.print(" | AcZ = "); Serial.print(AcZ);
// Serial.print(" | target = ");
Serial.println( (((AcY-target)/1000)>1) );
if(((AcY-target)/1000)>1)
{digitalWrite(13, HIGH);delay(1600);digitalWrite(13, LOW);}
// Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53); //equation for temperature in degrees C from datasheet
// Serial.print(" | GyX = "); Serial.print(GyX);
// Serial.print(" | GyY = "); Serial.print(GyY);
// Serial.print(" | GyZ = "); Serial.println(GyZ);
delay(200);
}
i m onlu using my mpu on Y axis but still its not fulfilling my purpose i m using 8x9 matric or 4leg rgb leds on a veroboard and using #arduino_nano
help me plsss