stm32mpu6050驱动代码,数码管显示角度。程序使用了dmp,且自动校准,用数码管显示一个方向的角度,其余方向也全读出来了,在代码里有
这文件是一些必要的资料
这是源代码:
完整源码下载:
角度仪—数码管.rar
(10.55 MB, 下载次数: 85)
主程序预览(完整代码请下载附件):
- #include "led.h"
- #include "delay.h"
- #include "sys.h"
- #include "usart.h"
- #include "lcd.h"
- #include "anbt_dmp_fun.h"
- #include "anbt_i2c.h"
- #include "anbt_dmp_mpu6050.h"
- #include "anbt_dmp_driver.h"
- #include "LED_NUM.h"
- void uart_send_status(float Pitch,float Roll,float Yaw) ;
- u16 count=10000;
- u8 get_pose_flag = 0;
- extern u8 LED[4];
-
- int main(void)
- {
- SystemInit(); //系统时钟等初始化
- delay_init(72); //延时初始化
- uart_init(115200); //串口初始化为115200
- LCD_Init();
- LCD_Clear(BLUE);
- BACK_COLOR=BLUE;
- POINT_COLOR=YELLOW;
- LCD_ShowString(24,24,64,16,16,"X_ANGLE:");
- LCD_ShowString(24,48,64,16,16,"Y_ANGLE:");
- LCD_ShowString(24,72,64,16,16,"Z_ANGLE:");
-
- POINT_COLOR=RED;
- LCD_WriteNUM_float(128,24,Pitch,16);
- LCD_WriteNUM_float(128,48,Roll,16);
- LCD_WriteNUM_float(128,72,Yaw,16);
- ANBT_I2C_Configuration(); //IIC初始化
- AnBT_DMP_MPU6050_Init(); //6050DMP初始化,关闭去除偏移量,自动水平校准
- NVIC_Configuration(); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
- LED_NUM_Init();
- while(1)
- {
- POINT_COLOR=RED;
- LCD_WriteNUM_float(128,24,Pitch,16);
- LCD_WriteNUM_float(128,48,Roll,16);
- LCD_WriteNUM_float(128,72,Yaw,16);
- // printf(" %8f %8f %8f\n\r",Pitch, Roll, Yaw);
- UART1_Put_Char((int)(Pitch*10)%256);UART1_Put_Char((int)(Pitch*10)/256);
- UART1_Put_Char((int)(Roll*10)%256);UART1_Put_Char((int)(Roll*10)/256);
- UART1_Put_Char((int)(Yaw*10)%256);UART1_Put_Char((int)(Yaw*10)/256);
- }
- }
- void EXTI1_IRQHandler(void)
- {
- if(EXTI_GetITStatus(EXTI_Line1) != RESET)
- {
- MPU6050_Pose();
- LED_NUM_Display();
- }
- EXTI_ClearITPendingBit(EXTI_Line1);
- }
复制代码
|