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
00001 #include "mbed.h" 00002 #include "MPU6050.h" 00003 DigitalOut myled(PC_13); 00004 MPU6050 mpu6050(PB_7,PB_6); 00005 Serial pc(PA_2, PA_3,9600); 00006 float yaw,pitch,roll; 00007 int counts; 00008 int main() 00009 { 00010 pc.printf("Initializing...\n"); 00011 while(mpu6050.Init()) //初始化 00012 { 00013 counts+=1; 00014 wait(1); 00015 myled=!myled; 00016 if(counts>10) 00017 { 00018 pc.printf("Initialation failed\n"); // 初始化失败 00019 break; 00020 } 00021 } 00022 pc.printf("Initialized\n"); //初始化完成 00023 while(1) 00024 { 00025 mpu6050.receiveData(&yaw,&pitch,&roll); //读取传感器姿态 00026 pc.printf("Yaw, Pitch, Roll: %f %f %f\n\r", yaw, pitch, roll); 00027 } 00028 }
Generated on Tue Jul 12 2022 18:19:54 by
1.7.2