#include <Wire.h>
#include <MPU6050_light.h>
#define RESET_BUTTON_PIN 15
MPU6050 mpu(Wire);
void setup() {
Serial.begin(115200);
Wire.begin(21, 22);
pinMode(RESET_BUTTON_PIN, INPUT_PULLUP);
Serial.println("Initializing MPU6050...");
mpu.begin();
mpu.calcGyroOffsets();
Serial.println("MPU6050 ready!");
}
void loop() {
mpu.update();
if (digitalRead(RESET_BUTTON_PIN) == LOW) {
Serial.println("Reset button pressed. Recalibrating...");
mpu.calcGyroOffsets();
}
Serial.print("Gyro X: "); Serial.print(mpu.getGyroX());
Serial.print(" | Y: "); Serial.print(mpu.getGyroY());
Serial.print(" | Z: "); Serial.println(mpu.getGyroZ());
delay(1000);
}