#include <LiquidCrystal.h>
#include "MPU6050.h"
MPU6050 mpu;
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
int16_t x, y, z;
float ax, ay, az;
void setup(void)
{
Wire.begin();
mpu.initialize();
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0,0);
}
void loop(void)
{
ax = 0;
ay = 0;
az = 0;
for(int i = 0; i<10; i++){
x = mpu.getAccelerationX();
y = mpu.getAccelerationY();
z = mpu.getAccelerationZ();
ax += ((float)x/32768*2);
ay += ((float)y/32768*2);
az += ((float)z/32768*2);
delay(100);
}
ax = ax/10;
ay = ay/10;
az = az/10;
lcd.setCursor(0,0);
lcd.print("X=");
lcd.print(ax);
lcd.print(" ");
lcd.setCursor(8,0);
lcd.print("Y=");
lcd.print(ay);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("Z=");
lcd.print(az);
lcd.print(" ");
}