元件包括驅動芯片L298N,整流二極管,電機,由于是四輪,固有四個電機穩壓模塊L7805等
電路原理圖如下:
51hei截圖20200314114656.png (38.61 KB, 下載次數: 88)
下載附件
驅動電路
2020-3-14 11:49 上傳
51hei截圖20200314114645.png (81.97 KB, 下載次數: 70)
下載附件
2020-3-14 11:51 上傳
51hei截圖20200314114708.png (15.6 KB, 下載次數: 73)
下載附件
2020-3-14 11:51 上傳
51hei截圖20200314114715.png (24.18 KB, 下載次數: 78)
下載附件
2020-3-14 11:51 上傳
單片機源程序如下:
- #include"motor_pwm.h"
- sbit hw=P1^0;
- sbit key=P3^6;
- sbit key1=P3^7;
- sbit fengji=P3^4;
- void main(void)
- {
- uint T1_data=0;
- uchar flag;
- uint count,aaa;
- char pwm_l=52,pwm_r=52;
- pwm_init();
- // int_init();
- // Timer1_Init();
- while(1)
- {
- if(!key1){while(!key1);fengji=~fengji;}//吸塵風機打開/關閉開關
- if(!key){while(!key);flag++;if(flag>2)flag=0;}//模式切換
- if(flag==1)//模式一 來回往返清掃模式
- {
- motor(pwm_l,pwm_r);
-
- if(!hw)
- {
- if(aaa)
- {
- aaa=0;
- count=100;while(count--){Delay(10);motor(0,0);}//停止1S
- //count=100;while(count--){Delay(10);motor(-25,-25);}//后退1S
- count=100;while(count--){Delay(40);motor(65,-65);}//右轉90度
- count=100;while(count--){Delay(27);motor(65,65);}//前進1S
- count=100;while(count--){Delay(32);motor(65,-65);}//右轉90度
- count=100;while(count--){Delay(45);motor(-50,-50);}//后退2S
- }
- else
- {
- aaa=1;
- count=100;while(count--){Delay(10);motor(0,0);}//停止1S
- //count=100;while(count--){Delay(10);motor(-25,-25);}//后退1S
- count=100;while(count--){Delay(40);motor(-65,65);}//右轉90度
- count=100;while(count--){Delay(27);motor(65,65);}//前進1S
- count=100;while(count--){Delay(30);motor(-65,65);}//右轉90度
- count=100;while(count--){Delay(45);motor(-50,-50);}//后退2S
- }
- }
- }
- else if(flag==2)//模式二 任意清掃模式
- {
- motor(50,50);
- if(!hw)
- {
-
- count=100;while(count--){Delay(12);motor(-50,-50);}//后退1S
- count=100;while(count--){Delay(34);motor(-50,50);}//右轉90度
-
- // count=100;while(count--){Delay(12);motor(-50,-50);}//后退1S
- // count=100;while(count--){Delay(34);motor(-50,50);}//右轉90度
-
- }
- }
- else if(flag==0)//停止模式
- {
- motor(0,0);
- }
-
-
-
- }
- }
復制代碼
所有資料51hei提供下載:
掃地機器人源程序.rar
(24.24 KB, 下載次數: 83)
2020-3-14 11:52 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|