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@5:874e0af6fb50, 2020-03-25 (annotated)
- Committer:
- Richard_Xiong
- Date:
- Wed Mar 25 19:10:36 2020 +0000
- Revision:
- 5:874e0af6fb50
- Parent:
- 2:0c1c9795bfc4
- Child:
- 6:29ccbdd09706
include IMU
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| dyu2021 | 0:ae05ad9e2610 | 1 | #include "mbed.h" |
| dyu2021 | 0:ae05ad9e2610 | 2 | |
| Richard_Xiong | 2:0c1c9795bfc4 | 3 | uLCD_4DGL uLCD(p28, p27, p30); |
| Richard_Xiong | 5:874e0af6fb50 | 4 | LSM9DS1 my_imu(p9, p10, 0xD6, 0x3C); |
| Richard_Xiong | 2:0c1c9795bfc4 | 5 | |
| Richard_Xiong | 2:0c1c9795bfc4 | 6 | int Steps; |
| Richard_Xiong | 2:0c1c9795bfc4 | 7 | |
| dyu2021 | 0:ae05ad9e2610 | 8 | int main() { |
| Richard_Xiong | 5:874e0af6fb50 | 9 | // set upo the display |
| Richard_Xiong | 5:874e0af6fb50 | 10 | |
| Richard_Xiong | 2:0c1c9795bfc4 | 11 | uLCD.display_control(PORTRAIT); |
| Richard_Xiong | 2:0c1c9795bfc4 | 12 | uLCD.cls(); |
| 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 | 5:874e0af6fb50 | 21 | port.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 | 5:874e0af6fb50 | 25 | |
| Richard_Xiong | 5:874e0af6fb50 | 26 | |
| Richard_Xiong | 2:0c1c9795bfc4 | 27 | |
| Richard_Xiong | 2:0c1c9795bfc4 | 28 | while (1) { |
| Richard_Xiong | 5:874e0af6fb50 | 29 | //reading the acceleration/Mag/Gyro data information from the imu |
| Richard_Xiong | 5:874e0af6fb50 | 30 | my_imu.readAccel(); |
| Richard_Xiong | 5:874e0af6fb50 | 31 | my_imu.readMag(); |
| Richard_Xiong | 5:874e0af6fb50 | 32 | my_imu.readGyro(); |
| Richard_Xiong | 5:874e0af6fb50 | 33 | |
| Richard_Xiong | 5:874e0af6fb50 | 34 | // print the information to the LCD display |
| Richard_Xiong | 2:0c1c9795bfc4 | 35 | uLCD.printf("Your steps right now is %d",steps); |
| Richard_Xiong | 5:874e0af6fb50 | 36 | uLCD.printf("gyro: %d %d %d\n\r", my_imu.gx, my_imu.gy, my_imu.gz); |
| Richard_Xiong | 5:874e0af6fb50 | 37 | uLCD.printf("accel: %d %d %d\n\r", my_imu.ax, my_imu.ay, my_imu.az); |
| Richard_Xiong | 5:874e0af6fb50 | 38 | uLCD.printf("mag: %d %d %d\n\n\r", my_imu.mx, my_imu.my, my_imu.mz); |
| dyu2021 | 0:ae05ad9e2610 | 39 | } |
| Richard_Xiong | 2:0c1c9795bfc4 | 40 | |
| dyu2021 | 0:ae05ad9e2610 | 41 | } |

