|
52智能小車+紅外遙控+超聲波,紅外避障+PWM波調(diào)速度+超聲波測(cè)距+測(cè)小車行駛速度,距離+紅外循跡
單片機(jī)源程序如下:
- /***************************************
- 《智能小車》
- 作者: 歡。
- 功能: 紅外遙控
- 超聲波,紅外避障
- PWM波調(diào)速度
- 超聲波測(cè)距
- 測(cè)小車行駛速度,行走路程
- 紅外循跡
-
- *****************************************/
- #include "reg52.h"
- #include "CarControl.h"
- #include "lcd1602.h"
- #include "SuperWave.h"
- #include "IRLED.h"
- #include "MeasureSpeed.h"
- #define uchar unsigned char
- #define uint unsigned int
- sfr IPH = 0XB7;//優(yōu)先級(jí)配置寄存器
- sbit IRIN = P3^3; //紅外接收器數(shù)據(jù)線
- extern uchar IRLedValue ;//紅外遙控器值
- extern bit RedTracking;//是否循跡
- bit IsCarRunning=0;//車是否在跑
- /***************************************
-
- 定時(shí)器0:計(jì)數(shù)器模式,用于計(jì)算碼盤脈沖個(gè)數(shù)
- 定時(shí)器1:定時(shí)器模式,用于計(jì)算超聲波距離
- 定時(shí)器2:定時(shí)器模式,產(chǎn)生PWM波
- 外部中斷0:紅外接收中斷
- 優(yōu)先級(jí):
- 外部中斷0 > 定時(shí)器2 > 定時(shí)器1 > 定時(shí)器0
- *****************************************/
- void main()
- {
- PT0=1; //提升外部中斷1高于定時(shí)器0
- IPH|=0x22;//提升定時(shí)器2優(yōu)先級(jí)僅次于外部中斷1
- PWMinit();
- LCD_Init();
- SuperWave_Init();
- IRLED_Init();
- MeasureSpeed_Init_T0();
- LCD_Write_String(0,0,"Num: ");
- while(1)
- {
- if(RedTracking == 0)
- {
- SuperWave_GetCount();
- }
- else
- {
- Tracking();
- }
- }
- }
復(fù)制代碼
所有資料51hei提供下載:
智能遙控小車.rar
(70.91 KB, 下載次數(shù): 99)
2019-11-11 16:11 上傳
點(diǎn)擊文件名下載附件
52智能小車+紅外遙控+超聲波,紅外避障+PWM波調(diào)速度+超聲波測(cè)距+測(cè)小車行駛速度,距離。 下載積分: 黑幣 -5
|
|