52智能小車+紅外遙控+超聲波,紅外避障+PWM波調速度+超聲波測距+測小車行駛速度,距離+紅外循跡
單片機源程序如下:
- /***************************************
- 《智能小車》
- 作者: 歡。
- 功能: 紅外遙控
- 超聲波,紅外避障
- PWM波調速度
- 超聲波測距
- 測小車行駛速度,行走路程
- 紅外循跡
-
- *****************************************/
- #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;//優先級配置寄存器
- sbit IRIN = P3^3; //紅外接收器數據線
- extern uchar IRLedValue ;//紅外遙控器值
- extern bit RedTracking;//是否循跡
- bit IsCarRunning=0;//車是否在跑
- /***************************************
-
- 定時器0:計數器模式,用于計算碼盤脈沖個數
- 定時器1:定時器模式,用于計算超聲波距離
- 定時器2:定時器模式,產生PWM波
- 外部中斷0:紅外接收中斷
- 優先級:
- 外部中斷0 > 定時器2 > 定時器1 > 定時器0
- *****************************************/
- void main()
- {
- PT0=1; //提升外部中斷1高于定時器0
- IPH|=0x22;//提升定時器2優先級僅次于外部中斷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();
- }
- }
- }
復制代碼
所有資料51hei提供下載:
智能遙控小車.rar
(70.91 KB, 下載次數: 99)
2019-11-11 16:11 上傳
點擊文件名下載附件
52智能小車+紅外遙控+超聲波,紅外避障+PWM波調速度+超聲波測距+測小車行駛速度,距離。 下載積分: 黑幣 -5
|