#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)
2023-7-22 15:08 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|