#include <Wire.h>
#include <MPU6050.h>
MPU6050 mpu;
const int ledPin = 13; // Assuming you have an LED connected to pin 13
void setup() {
Serial.begin(9600);
Wire.begin();
mpu.initialize();
pinMode(ledPin, OUTPUT); // Set the LED pin as an output
}
void loop() {
int16_t gyroX, gyroY, gyroZ;
mpu.getRotation(&gyroX, &gyroY, &gyroZ);
Serial.print("\tGyro Z: ");
Serial.println(gyroZ);
// Check if gyroZ reaches 1000
if (gyroZ >= 2000) {
// Turn on the LED
digitalWrite(ledPin, HIGH);
} else {
// Turn off the LED
digitalWrite(ledPin, LOW);
}
delay(1000);
}