#include "I2Cdev.h" #include "MPU6050.h" #define TIME_OUT 20 int16_t ax, ay, az, gx, gy, gz; MPU6050 accgyro; int x = 0; int y = 0; void setup() { Serial.begin(9600); accgyro.initialize(); } void loop() { accgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); x = gx; accgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); y = gy; Serial.println((String(x) + String(" - ") + String(y))); delay(300); }
Открыть пример: Online ArduBlock
Видеоурок: