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
- Committer:
- AlexQian
- Date:
- 2019-03-17
- Revision:
- 3:dd03d585a24f
- Parent:
- 1:cea9d83b8636
File content as of revision 3:dd03d585a24f:
#include "mbed.h"
#include "MPU6050.h"
DigitalOut myled(PC_13);
MPU6050 mpu6050(PB_7,PB_6);
Serial pc(PA_2, PA_3,9600);
float yaw,pitch,roll;
int counts;
int main()
{
pc.printf("Initializing...\n");
while(mpu6050.Init()) //初始化
{
counts+=1;
wait(1);
myled=!myled;
if(counts>10)
{
pc.printf("Initialation failed\n"); // 初始化失败
break;
}
}
pc.printf("Initialized\n"); //初始化完成
while(1)
{
mpu6050.receiveData(&yaw,&pitch,&roll); //读取传感器姿态
pc.printf("Yaw, Pitch, Roll: %f %f %f\n\r", yaw, pitch, roll);
}
}