欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 各種單片機小車程序集合 [打印本頁]

作者: 2983606955    時間: 2020-12-22 09:40
標題: 各種單片機小車程序集合
有小車循跡
有紅外遙控
有聲控小車
有超聲波避障


電路原理圖如下:


單片機源程序如下:
  1. #include<reg52.h>

  2. #define uchar unsigned char
  3. #define uint unsigned int
  4. sbit pwm=P2^7;                                 //P2.7為PWM腳。
  5. uchar count,angle;                //計數和角度。


  6. void delay_100us()                         //100us延時,相當于0.1ms
  7. {
  8. uchar j;
  9.         for(j=0;j<31;j++)
  10.                 {
  11.                 ;
  12.                 }

  13. }

  14. void toji()
  15. {
  16.         while(count<200)        //count少于200時,無限循環,相當于20ms為一個周期
  17.                 {
  18.                         if(count<angle) //count少于角度。
  19.                         {
  20.                         pwm=1;                         //pwm輸出高電平。
  21.                
  22.        
  23.                         }                                                       

  24.                         else                        //其它情況
  25.                         {                          
  26.                         pwm=0;                         //pwm輸出低電平。

  27.                         }
  28.                    delay_100us();         //延時100us,相當于0.1ms

  29.                         count++;                 //count自加1。                
  30.                 }                                  
  31.          count=0;                                //當count經歷200次后,count歸0                               
  32. }



  33. void main()
  34. {
  35. count=0;

  36. while(1)
  37.         {                       
  38.          angle=5;  //角度為5ms
  39.          toji();         //調用舵機子程序。
  40.          


  41.          }

  42. }
復制代碼

所有資料51hei提供下載:
03 小車程序與電路.rar (3.23 MB, 下載次數: 53)






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