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.
Dependencies: mbed PulseSensor2 SCP1000 mbed-rtos 4DGL-uLCD-SE LSM9DS1_Library_cal PinDetect FatFileSystemCpp GP-20U7
Diff: main.cpp
- Revision:
- 5:874e0af6fb50
- Parent:
- 2:0c1c9795bfc4
- Child:
- 6:29ccbdd09706
--- a/main.cpp	Wed Mar 25 19:04:16 2020 +0000
+++ b/main.cpp	Wed Mar 25 19:10:36 2020 +0000
@@ -1,21 +1,41 @@
 #include "mbed.h"
 
 uLCD_4DGL uLCD(p28, p27, p30);
+LSM9DS1 my_imu(p9, p10, 0xD6, 0x3C);
 
 int Steps;
 
-
 int main() {
+    // set upo the display
+    
     uLCD.display_control(PORTRAIT);
     uLCD.cls();
     uLCD.baudrate(BAUD_3000000);
     uLCD.background_color(BLACK);
     uLCD.cls();
     wait(0.5);
+    
+    //set up the imu 
+    my_imu.begin();
+    if (!my_imu.begin()) {
+        port.printf("Failed to communicate with LSM9DS1.\n");
+    }
+    my_imu.calibrate();
+
+    
+    
 
     while (1) { 
+    //reading the acceleration/Mag/Gyro data information from the imu
+    my_imu.readAccel();
+    my_imu.readMag();
+    my_imu.readGyro();
+    
+    // print the information to the LCD display
     uLCD.printf("Your steps right now is %d",steps);
-    
+    uLCD.printf("gyro: %d %d %d\n\r", my_imu.gx, my_imu.gy, my_imu.gz);
+    uLCD.printf("accel: %d %d %d\n\r", my_imu.ax, my_imu.ay, my_imu.az);
+    uLCD.printf("mag: %d %d %d\n\n\r", my_imu.mx, my_imu.my, my_imu.mz);
     }
     
 }
    
