#include <Wire.h>
#include <LiquidCrystal.h>
#include <MPU6050.h>
MPU6050 mpu;
LiquidCrystal lcd(12, 11, 10, 9, 8, 7); // change these pin numbers to match your setup
void setup() {
lcd.begin(16, 2); // initialize the LCD screen
Wire.begin(); // initialize I2C bus
mpu.initialize(); // initialize MPU6050 sensor
mpu.setFullScaleGyroRange(MPU6050_GYRO_FS_250); // set gyro range to +/-250 degrees/sec
mpu.setFullScaleAccelRange(MPU6050_ACCEL_FS_2); // set accelerometer range to +/-2g
}
void loop() {
int16_t ax, ay, az, gx, gy, gz;
mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); // read sensor data
// display sensor data on the LCD screen
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Accel: ");
lcd.print(ax); lcd.print(", ");
lcd.print(ay); lcd.print(", ");
lcd.print(az);
lcd.setCursor(0, 1);
lcd.print("Gyro: ");
lcd.print(gx); lcd.print(", ");
lcd.print(gy); lcd.print(", ");
lcd.print(gz);
delay(100); // wait for 100 milliseconds before reading sensor data again
}