![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
mbed I2C MPU6500 tilt angle
Fork of NTOUEE-mbed-I2C_MPU6500_Tiltangle by
Diff: main.cpp
- Revision:
- 0:73a95126993e
- Child:
- 1:efa4c7817836
diff -r 000000000000 -r 73a95126993e main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Oct 20 13:16:22 2016 +0000 @@ -0,0 +1,26 @@ +// using NuMaker-PFM-NUC472 I2C0 to read 3-axis accelerometer & 3-axis gyroscope (MPU6500) +#include "mbed.h" +#include "mpu6500.h" + +I2C i2c0(PC_9, PA_15); // I2C0_SDA, I2C0_SCL + +MPU6500 IMU; // on-board IMU is MPU6500 + +int main() { + int16_t accX, accY, accZ; + int16_t gyroX, gyroY, gyroZ; + + i2c0.frequency(400000); + IMU.initialize(); + + while(true) { + accX = IMU.getAccelXvalue(); + accY = IMU.getAccelYvalue(); + accZ = IMU.getAccelZvalue(); + gyroX= IMU.getGyroXvalue(); + gyroY= IMU.getGyroYvalue(); + gyroZ= IMU.getGyroZvalue(); + printf("Acc: %6d, %6d, %6d, ", accX, accY, accZ); + printf("Gyro:%6d, %6d, %6d\n\r", gyroX, gyroY, gyroZ); + } +}