#include "stm32f10x.h" // Device header
#include "PWM.h"
#include "delay.h"
#include "Motor.h"
#include "RedRay.h"
//循迹,通过判断三个光电对管的状态来控制LED灯
void SearchRun(void)
{
if(SEARCH_M_IO == BLACK_AREA && SEARCH_L_IO == BLACK_AREA && SEARCH_R_IO == BLACK_AREA )
{
if(SEARCH_M_IO == BLACK_AREA && SEARCH_L_IO == BLACK_AREA && SEARCH_R_IO == BLACK_AREA )
{
delay(10);
Motor_R_SetSpeed(40);
Motor_L_SetSpeed2(40);
}
}
else if(SEARCH_L_IO == BLACK_AREA )
{
Motor_R_SetSpeed(60);
Motor_L_SetSpeed2(40);
}
else if(SEARCH_R_IO == BLACK_AREA )
{
Motor_R_SetSpeed(40);
Motor_L_SetSpeed2(60);
}
}
int main()
{
Motor_Init();
while(1)
{
SearchRun();
}
}
原理图: 无
仿真: 无
Keil代码:
代码.7z
(180.6 KB, 下载次数: 12)
|