#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <MPU6050.h>
MPU6050 accelgyro;
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display
void setup() {
Serial.begin(115200);
Wire.begin();
Wire.setClock(400000); // set I2C clock to 400kHz
accelgyro.initialize(); // initialize MPU6050
lcd.init(); // initialize LCD
lcd.backlight(); // turn on LCD backlight
}
void loop() {
float yAccel = accelgyro.getAccelerationY(); // get y-axis acceleration
lcd.setCursor(0, 0); // set cursor to top left of LCD
lcd.print("Y-axis Accel: "); // print label
lcd.print(yAccel); // print y-axis acceleration value
lcd.print(" g"); // print unit of acceleration
delay(1000); // wait for 1 second before updating again
}