#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <MPU6050.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
MPU6050 mpu;
void setup() {
lcd.init();
lcd.backlight();
Wire.begin();
mpu.initialize();
}
void loop() {
int16_t ax, ay, az, gx, gy, gz;
mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
float pitch = gy/131;
float roll = gx/131;
float ax_f = (float)ax / 16384.0;
float ay_f = (float)ay / 16384.0;
float az_f = (float)az / 16384.0;
float gforce = sqrt(ax*ax + ay*ay + az*az)/16384;
lcd.setCursor(0, 0);
lcd.print(pitch, 1);
lcd.setCursor(7, 0);
lcd.print(roll, 1);
lcd.setCursor(0, 1);
lcd.print("G: ");
lcd.print(gforce, 2);
;
delay(100);
}