Sherry Yang
/
LSM6DS3_Demo
Demo for LSM6DS3
Fork of LSM9DS1_Demo by
Diff: main.cpp
- Revision:
- 1:acf696b18c52
- Parent:
- 0:9632b831b6c1
- Child:
- 3:c450734baa8b
--- a/main.cpp Mon Oct 19 16:52:59 2015 +0000 +++ b/main.cpp Thu Jun 16 20:07:34 2016 +0000 @@ -1,17 +1,17 @@ -// LSM9DS91 Demo +// LSM6DS3 Demo #include "mbed.h" -#include "LSM9DS1.h" +#include "LSM6DS3.h" // refresh time. set to 500 for part 2 and 50 for part 4 #define REFRESH_TIME_MS 1000 // Verify that the pin assignments below match your breadboard -LSM9DS1 imu(p9, p10); +LSM6DS3 imu(p30, p7); -Serial pc(USBTX, USBRX); +Serial pc(p9, p11); -//Init Serial port and LSM9DS1 chip +//Init Serial port and LSM6DS3 chip void setup() { // Use the begin() function to initialize the LSM9DS0 library. @@ -19,29 +19,33 @@ uint16_t status = imu.begin(); //Make sure communication is working - pc.printf("LSM9DS1 WHO_AM_I's returned: 0x%X\r\n", status); - pc.printf("Should be 0x683D\r\n"); + pc.printf("LSM6DS3 WHO_AM_I's returned: 0x%X\r\n", status); + pc.printf("Should be 0x69\r\n"); } int main() { setup(); //Setup sensor and Serial - pc.printf("------ LSM9DS1 Demo -----------\r\n"); + pc.printf("\r\n------ LSM6DS3 Demo -----------\r\n"); while (true) { + imu.readTemp(); + pc.printf("Temp:\r\n"); + pc.printf("TC: %2f\r\n", imu.temperature_c); + pc.printf("TF: %2f\r\n", imu.temperature_f); imu.readAccel(); - - pc.printf("A: %2f, %2f, %2f\r\n", imu.ax, imu.ay, imu.az); + pc.printf("Accel:\r\n"); + pc.printf("AX: %2f\r\n", imu.ax); + pc.printf("AY: %2f\r\n", imu.ay); + pc.printf("AZ: %2f\r\n", imu.az); imu.readGyro(); - - pc.printf("G: %2f, %2f, %2f\r\n", imu.gx, imu.gy, imu.gz); - - imu.readMag(); - - pc.printf("M: %2f, %2f, %2f\r\n\r\n", imu.mx, imu.my, imu.mz); + pc.printf("Gyro:\r\n"); + pc.printf("GX: %2f\r\n", imu.gx); + pc.printf("GY: %2f\r\n", imu.gy); + pc.printf("GZ: %2f\r\n\r\n", imu.gz); wait_ms(REFRESH_TIME_MS); }