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
main.cpp@7:fb47593628be, 2020-03-25 (annotated)
- Committer:
- Richard_Xiong
- Date:
- Wed Mar 25 19:17:28 2020 +0000
- Revision:
- 7:fb47593628be
- Parent:
- 6:29ccbdd09706
- Child:
- 20:adb9e6e1ad22
fixed some bugs
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| dyu2021 | 0:ae05ad9e2610 | 1 | #include "mbed.h" | 
| Richard_Xiong | 7:fb47593628be | 2 | #include "LSM9DS1.h" | 
| Richard_Xiong | 7:fb47593628be | 3 | #include "uLCD_4DGL.h" | 
| dyu2021 | 0:ae05ad9e2610 | 4 | |
| Richard_Xiong | 2:0c1c9795bfc4 | 5 | uLCD_4DGL uLCD(p28, p27, p30); | 
| Richard_Xiong | 5:874e0af6fb50 | 6 | LSM9DS1 my_imu(p9, p10, 0xD6, 0x3C); | 
| Richard_Xiong | 2:0c1c9795bfc4 | 7 | |
| Richard_Xiong | 2:0c1c9795bfc4 | 8 | int Steps; | 
| Richard_Xiong | 2:0c1c9795bfc4 | 9 | |
| dyu2021 | 0:ae05ad9e2610 | 10 | int main() { | 
| Richard_Xiong | 6:29ccbdd09706 | 11 | // set up the display | 
| Richard_Xiong | 2:0c1c9795bfc4 | 12 | uLCD.display_control(PORTRAIT); | 
| Richard_Xiong | 2:0c1c9795bfc4 | 13 | uLCD.baudrate(BAUD_3000000); | 
| Richard_Xiong | 2:0c1c9795bfc4 | 14 | uLCD.background_color(BLACK); | 
| Richard_Xiong | 2:0c1c9795bfc4 | 15 | uLCD.cls(); | 
| Richard_Xiong | 2:0c1c9795bfc4 | 16 | wait(0.5); | 
| Richard_Xiong | 5:874e0af6fb50 | 17 | |
| Richard_Xiong | 5:874e0af6fb50 | 18 | //set up the imu | 
| Richard_Xiong | 5:874e0af6fb50 | 19 | my_imu.begin(); | 
| Richard_Xiong | 5:874e0af6fb50 | 20 | if (!my_imu.begin()) { | 
| Richard_Xiong | 7:fb47593628be | 21 | uLCD.printf("Failed to communicate with LSM9DS1.\n"); | 
| Richard_Xiong | 5:874e0af6fb50 | 22 | } | 
| Richard_Xiong | 5:874e0af6fb50 | 23 | my_imu.calibrate(); | 
| Richard_Xiong | 5:874e0af6fb50 | 24 | |
| Richard_Xiong | 2:0c1c9795bfc4 | 25 | while (1) { | 
| Richard_Xiong | 5:874e0af6fb50 | 26 | //reading the acceleration/Mag/Gyro data information from the imu | 
| Richard_Xiong | 5:874e0af6fb50 | 27 | my_imu.readAccel(); | 
| Richard_Xiong | 5:874e0af6fb50 | 28 | my_imu.readMag(); | 
| Richard_Xiong | 5:874e0af6fb50 | 29 | my_imu.readGyro(); | 
| Richard_Xiong | 5:874e0af6fb50 | 30 | |
| Richard_Xiong | 5:874e0af6fb50 | 31 | // print the information to the LCD display | 
| Richard_Xiong | 2:0c1c9795bfc4 | 32 | uLCD.printf("Your steps right now is %d",steps); | 
| Richard_Xiong | 5:874e0af6fb50 | 33 | uLCD.printf("gyro: %d %d %d\n\r", my_imu.gx, my_imu.gy, my_imu.gz); | 
| Richard_Xiong | 5:874e0af6fb50 | 34 | uLCD.printf("accel: %d %d %d\n\r", my_imu.ax, my_imu.ay, my_imu.az); | 
| Richard_Xiong | 5:874e0af6fb50 | 35 | uLCD.printf("mag: %d %d %d\n\n\r", my_imu.mx, my_imu.my, my_imu.mz); | 
| dyu2021 | 0:ae05ad9e2610 | 36 | } | 
| Richard_Xiong | 2:0c1c9795bfc4 | 37 | |
| dyu2021 | 0:ae05ad9e2610 | 38 | } | 

