Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of NTOUEE-mbed-I2C_MPU6500 by
main.cpp
- Committer:
- rkuo2000
- Date:
- 2016-10-26
- Revision:
- 1:b8d0e8f53e6c
- Parent:
- 0:95e46ae24046
File content as of revision 1:b8d0e8f53e6c:
/// 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);
}
}
