forked from logzhan/RobotHardware-UESTC
76 lines
1.6 KiB
C
76 lines
1.6 KiB
C
/******************** (C) COPYRIGHT 2023 GeekRebot *****************************
|
|
* File Name : main.c
|
|
* Current Version : V1.0 & ST 3.5.0
|
|
* Author : zhanli 719901725@qq.com
|
|
* Date of Issued : 2023.04.06 zhanli: Create
|
|
* Comments : GeekRebot STM32
|
|
********************************************************************************/
|
|
#include "bsp_sys.h"
|
|
#include "stdio.h"
|
|
#include "bluetooth.h"
|
|
|
|
unsigned char BLE_RX[64];
|
|
/**----------------------------------------------------------------------
|
|
* Function : main
|
|
* Description : GeekRebot
|
|
* Author : zhanli&719901725@qq.com
|
|
* Date : 2023/04/22 zhanli
|
|
*---------------------------------------------------------------------**/
|
|
int main(void)
|
|
{
|
|
System_Init();
|
|
Bluetooth_Init(9600);
|
|
|
|
Car_Stop();
|
|
while (1)
|
|
{
|
|
Delay_ms(100);
|
|
USART2_Receive(BLE_RX, 6);
|
|
|
|
//USART2_Send(BLE_RX, 6);
|
|
//Delay_ms(500);
|
|
//printf("hello world\n");
|
|
if((BLE_RX[3] == 0xB1)&&(BLE_RX[4]==0xB5))
|
|
{
|
|
// SetPoint = SetPoint + 10;
|
|
BLE_RX[3] = 0x00;
|
|
}
|
|
|
|
if((BLE_RX[3] == 0xB3)&&(BLE_RX[4]==0xB7))
|
|
{
|
|
// SetPoint = SetPoint - 10;
|
|
BLE_RX[3] = 0x00;
|
|
}
|
|
|
|
if((BLE_RX[3] == 0xB2)&&(BLE_RX[4]==0xB6))
|
|
{
|
|
Car_Go();
|
|
}
|
|
if((BLE_RX[3] == 0xB4)&&(BLE_RX[4]==0xB8))
|
|
{
|
|
|
|
Car_Turn_Left();
|
|
// Delay_ms(500);
|
|
// Car_Go();
|
|
BLE_RX[3] = 0x00;
|
|
}
|
|
if((BLE_RX[3] == 0xB5)&&(BLE_RX[4]==0xB9))
|
|
{
|
|
Car_Stop();
|
|
}
|
|
if((BLE_RX[3] == 0xB6)&&(BLE_RX[4]==0xBA))
|
|
{
|
|
|
|
Car_Turn_Right();
|
|
// Delay_ms(500);
|
|
// Car_Go();
|
|
BLE_RX[3] = 0x00;
|
|
}
|
|
if((BLE_RX[3] == 0xB8)&&(BLE_RX[4]==0xBC))
|
|
{
|
|
Car_Back();
|
|
}
|
|
}
|
|
}
|
|
|