#include <Wire.h>
#include <MPU6050.h>
MPU6050 sensorGyroskop;
void setup() {
Serial.begin(9600);
Wire.begin();
sensorGyroskop.initialize();
// Verifikasi koneksi
if (!sensorGyroskop.testConnection()) {
Serial.println("Koneksi MPU6050 gagal!");
while (1);
}
}
void loop() {
// Baca data gyro
int16_t gyroX = sensorGyroskop.getRotationX();
int16_t gyroY = sensorGyroskop.getRotationY();
int16_t gyroZ = sensorGyroskop.getRotationZ();
// Tampilkan data di Serial Monitor
Serial.print("Gyro X: ");
Serial.print(gyroX);
Serial.print(" Gyro Y: ");
Serial.print(gyroY);
Serial.print(" Gyro Z: ");
Serial.println(gyroZ);
delay(500); // Jeda setengah detik
}