標(biāo)題: 51單片機(jī)循跡小車程序 [打印本頁(yè)]

作者: bingtangxl    時(shí)間: 2023-5-23 00:21
標(biāo)題: 51單片機(jī)循跡小車程序
利用兩路紅外傳感器、51單片機(jī)制作的循跡小車


單片機(jī)源程序如下:
  1. #include <REGX51.H>
  2. #include <intrins.h>
  3. #include "car.h"

  4. sbit D1=P2^4;
  5. sbit D2=P2^6;

  6. //void Delay5ms()                //@11.0592MHz
  7. //{
  8. //        unsigned char i, j;

  9. //        i = 54;
  10. //        j = 199;
  11. //        do
  12. //        {
  13. //                while (--j);
  14. //        } while (--i);
  15. //}



  16. void xunji(void)
  17. {
  18.         if(D1==1&&D2==1)//全檢測(cè)到黑線
  19.         {
  20.                 car_go();
  21.         }
  22.         if(D1==0&&D2==1)//右側(cè)檢測(cè)到黑線,左邊檢測(cè)到白色,小車偏左,小車向右側(cè)移動(dòng)
  23.         {
  24.                 car_rightstop();

  25.         }
  26.         if(D1==1&&D2==0)//左側(cè)檢測(cè)到黑線,右邊檢測(cè)到白色小車偏右,小車向左側(cè)移動(dòng)
  27.         {
  28.                 car_leftstop();

  29.         }
  30.         if(D1==0&&D2==0)//如果同時(shí)白線則停止
  31.         {
  32.                 car_stop();
  33.         }
  34. }
  35.        
  36.        
  37.        
復(fù)制代碼

c文件下載:
循跡小車.zip (3.57 MB, 下載次數(shù): 27)




作者: liucan2020    時(shí)間: 2023-5-26 15:07
厲害,等有時(shí)間的時(shí)候 我也學(xué)著做一個(gè)
作者: lsh04    時(shí)間: 2023-5-27 09:58
厲害,等有時(shí)間的時(shí)候 我也學(xué)著做一個(gè)
作者: 啃西瓜    時(shí)間: 2023-6-8 17:46
很厲害。。∽罱锌找惨鲆粋(gè)




歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1