PCB抄板stm32f103的蓝牙开关控制舵机
- PCB抄板#include "stm32f10x.h"
- PCB抄板#include "usart1.h"
- PCB抄板#include "bluetooth.h"
- #include "key.h"
- #include "led.h"
- #include "motor.h"
- #include "runmodel.h"
- u8 motor_mode = 0; //电机运动模式
- u8 send_flag = 0;
- int main(void)
- {
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2); //中断控制器分组设置
- Key_Init(); //初始化按键
- EXTI_Configuration();
- Usart1_Init(115200); //设置串口1的波特率为115200bit
- LedInit(); //初始化led
- Delay_Init(); //初始化延迟函数
- BlueTooth_Init(); //初始化蓝牙模块
- USART_Cmd(USART1, ENABLE); //除能串口
- GPIO_ResetBits(GPIOB,EN);
- Motor_Init(); //舵机初始化
- Lo_Signal;
- while(1)
- {
- if(GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_8) == Bit_RESET)
- {
- DelayMs(100);
- if(GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_8) == Bit_RESET)
- {
- send_flag++;
- if(send_flag == 2)
- send_flag = 0;
- if(GPIO_ReadOutputDataBit(GPIOA,GPIO_Pin_2) == Bit_RESET)
- GPIO_SetBits(GPIOA,GPIO_Pin_2);
- else
- GPIO_ResetBits(GPIOA,GPIO_Pin_2);
-
- if(send_flag == 1)
- {
- Motor_Mode(Reverse_45);
- }
-
- if(send_flag == 0)
- {
- Motor_Mode(Forward_45);
- }
- }
- }
-
- }
- }

芯片解密