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.
main.cpp@3:dd03d585a24f, 2019-03-17 (annotated)
- Committer:
- AlexQian
- Date:
- Sun Mar 17 15:11:51 2019 +0000
- Revision:
- 3:dd03d585a24f
- Parent:
- 1:cea9d83b8636
MPU6050
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| onehorse | 1:cea9d83b8636 | 1 | #include "mbed.h" |
| onehorse | 1:cea9d83b8636 | 2 | #include "MPU6050.h" |
| AlexQian | 3:dd03d585a24f | 3 | DigitalOut myled(PC_13); |
| AlexQian | 3:dd03d585a24f | 4 | MPU6050 mpu6050(PB_7,PB_6); |
| AlexQian | 3:dd03d585a24f | 5 | Serial pc(PA_2, PA_3,9600); |
| AlexQian | 3:dd03d585a24f | 6 | float yaw,pitch,roll; |
| AlexQian | 3:dd03d585a24f | 7 | int counts; |
| onehorse | 1:cea9d83b8636 | 8 | int main() |
| AlexQian | 3:dd03d585a24f | 9 | { |
| AlexQian | 3:dd03d585a24f | 10 | pc.printf("Initializing...\n"); |
| AlexQian | 3:dd03d585a24f | 11 | while(mpu6050.Init()) //初始化 |
| onehorse | 1:cea9d83b8636 | 12 | { |
| AlexQian | 3:dd03d585a24f | 13 | counts+=1; |
| AlexQian | 3:dd03d585a24f | 14 | wait(1); |
| AlexQian | 3:dd03d585a24f | 15 | myled=!myled; |
| AlexQian | 3:dd03d585a24f | 16 | if(counts>10) |
| AlexQian | 3:dd03d585a24f | 17 | { |
| AlexQian | 3:dd03d585a24f | 18 | pc.printf("Initialation failed\n"); // 初始化失败 |
| AlexQian | 3:dd03d585a24f | 19 | break; |
| AlexQian | 3:dd03d585a24f | 20 | } |
| onehorse | 0:65aa78c10981 | 21 | } |
| AlexQian | 3:dd03d585a24f | 22 | pc.printf("Initialized\n"); //初始化完成 |
| AlexQian | 3:dd03d585a24f | 23 | while(1) |
| AlexQian | 3:dd03d585a24f | 24 | { |
| AlexQian | 3:dd03d585a24f | 25 | mpu6050.receiveData(&yaw,&pitch,&roll); //读取传感器姿态 |
| AlexQian | 3:dd03d585a24f | 26 | pc.printf("Yaw, Pitch, Roll: %f %f %f\n\r", yaw, pitch, roll); |
| AlexQian | 3:dd03d585a24f | 27 | } |
| onehorse | 1:cea9d83b8636 | 28 | } |