标题:
STM32单片机串口代码移植 HC-05蓝牙模块收发程序
[打印本页]
作者:
二货道士
时间:
2020-12-6 20:42
标题:
STM32单片机串口代码移植 HC-05蓝牙模块收发程序
单片机源程序如下:
#include "led.h"
#include "delay.h"
#include "key.h"
#include "sys.h"
#include "usart.h"
#include "exti.h"
#include "oled.h"
#include "mpu6050.h"
#include "inv_mpu.h"
#include "inv_mpu_dmp_motion_driver.h"
#include "bmp.h"
#include "timer.h"
// OLED_ShowPicture(32,0,96,4,BMP_go);
// OLED_ShowPicture(32,4,96,8,BMP_back);
//
// OLED_ShowPicture(0,0,32,8,BMP_left);
// OLED_ShowPicture(96,0,128,8,BMP_right);
float i=0,pitch=0,roll=0,yaw=0; //滚,仰,偏
int main(void)
{
delay_init(); //延时函数初始化
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级
uart_init(115200); //串口初始化为
LED_Init(); //LED端口初始化
EXTIX_KEY_Init();
MPU_Init();
OLED_Init();
while(mpu_dmp_init())
{
delay_ms(10);
}
while(1)
{
delay_ms(2);
if(mpu_dmp_get_data(&pitch,&roll,&yaw)==0)
{
LED=~LED;
}
if(pitch > 15 ) //右
{
OLED_ShowPicture(96,0,128,8,BMP_right);
USART_SendData(USART1, 4 );
}
else if(pitch < -15 ) //左
{
OLED_ShowPicture(0,0,32,8,BMP_left);
USART_SendData(USART1, 3 );
}
else if(roll < -15 ) //go
{
OLED_ShowPicture(32,0,96,4,BMP_go);
USART_SendData(USART1, 1 );
}
else if(roll > 15 ) //back
{
OLED_ShowPicture(32,4,96,8,BMP_back);
USART_SendData(USART1, 2 );
}
else
{
OLED_Clear();
USART_SendData(USART1, 5 );
}
}
}
复制代码
全部资料51hei下载地址:
单片机串口代码移植.7z
(261.71 KB, 下载次数: 40)
2020-12-6 23:21 上传
点击文件名下载附件
下载积分: 黑币 -5
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1