题目内容
#include "stm32f10x_heads.h"#include "HelloRobot.h"#define LeftLaunch_1 GPIO_SetBits(GPIOE, GPIO_Pin_1)//左边红外发射高电平#define LeftLaunch_0 GPIO_ResetBits(GPIOE, GPIO_Pin_1) //左边红外发射低电平(1) //右边红外发射高电平(2) //右边红外发射低电平#define LeftIR GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_3) //左边红外接收(3) //右边红外接收//发射函数(4)void Forward(void){(5)}void Left_Turn(void){(6)}void Right_Turn(void){(7)}void Backward(void){int i;for(i=1;i<=65;i++){GPIO_SetBits(GPIOD, GPIO_Pin_10);delay_nus(1300);GPIO_ResetBits(GPIOD,GPIO_Pin_10);GPIO_SetBits(GPIOD, GPIO_Pin_9);delay_nus(1300);GPIO_ResetBits(GPIOD,GPIO_Pin_9);delay_nms(20);}}int main(void){int irDetectLeft,irDetectRight;BSP_Init();while(1){IRLaunch('R'); //右边发射irDetectRight = RightIR;//右边接收(8)//左边发射(9)//左边接收//两边同时接收到红外线,掉头(10)//只有左边接收到红外线,右转(11)//只有右边接收到红外线,左转(12)//否则后退else//没有障碍物就前进(13)}}
查看答案
搜索结果不匹配?点我反馈