標題:
基于STM32單片機小車三路循跡代碼
[打印本頁]
作者:
想年薪五十萬
時間:
2023-7-22 11:27
標題:
基于STM32單片機小車三路循跡代碼
#include "stm32f10x.h" // Device header
#include "PWM.h"
#include "delay.h"
#include "Motor.h"
#include "RedRay.h"
//循跡,通過判斷三個光電對管的狀態(tài)來控制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, 下載次數(shù): 12)
2023-7-22 15:08 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1