接線見源碼頂部詳述
#include "stm32f10x.h"
#include "Delay.h"
#include "OLED.h"
#include "mpu6050.h"
#include "inv_mpu.h"
#include "inv_mpu_dmp_motion_driver.h"
int main (void)
{
float pitch,roll,yaw; //歐拉角
OLED_Init(); //OLED初始化
OLED_ShowString(1,1,"MPU6050"); OLED_ShowFontString(1,5,0,3); //“MPU6050姿態檢測”
OLED_ShowFontString(2,1,5,7); OLED_ShowFont(2,4,14); //“俯仰角:”
OLED_ShowFontString(3,1,8,10); OLED_ShowFont(3,4,14); //“橫滾角:”
OLED_ShowFontString(4,1,11,13); OLED_ShowFont(4,4,14); //“航偏角:”
while(mpu_dmp_init()) //初始化MPU6050
{
Delay_ms(20);
}
while(1)
{
if(mpu_dmp_get_data(&pitch,&roll,&yaw)==0) //若初始化成功則顯示各個角
{
OLED_ShowSignedNum(2,9,pitch,3);OLED_ShowFont(2,7,4);
OLED_ShowSignedNum(3,9,roll,3);OLED_ShowFont(3,7,4);
OLED_ShowSignedNum(4,9,yaw,3);OLED_ShowFont(4,7,4);
}
Delay_ms(20); //刷新頻率
}
}
原理圖:無
程序:
程序.7z
(214.11 KB, 下載次數: 28)
2023-8-8 14:45 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|