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

標題: STM32單片機智能小車基于灰度傳感器的巡線代碼 [打印本頁]

作者: 探索中的船長    時間: 2020-3-30 17:13
標題: STM32單片機智能小車基于灰度傳感器的巡線代碼
單片機源程序如下:
  1. #include "led.h"
  2. #include "delay.h"
  3. #include "key.h"
  4. #include "sys.h"
  5. #include "usart.h"         
  6. #include "adc.h"
  7. #include "timer.h"
  8. #include "car.h"

  9. /************************************************
  10. ADC    A0     A1     A2    A3
  11. PWM     TIM3 CH2A7     TIM3 CH1A6
  12.         F11高 F13低    F12高 F14低
  13. 中間灰度巡線 差速
  14. 旁邊轉(zhuǎn)彎   正反轉(zhuǎn)
  15. ************************************************/



  16. int main(void)
  17. {        
  18.         GPIO_Config();
  19.         delay_init();                     //延時函數(shù)初始化          
  20.         NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);//設(shè)置中斷優(yōu)先級分組為組2:2位搶占優(yōu)先級,2位響應(yīng)優(yōu)先級
  21.         uart_init(115200);                 //串口初始化為115200
  22.         LED_Init();                             //LED端口初始化
  23.         Adc_Init();                                  //ADC初始化
  24.   DMA_Config();
  25.   TIM3_PWM_Init(99,71);//頻率 10 KHZ
  26.          
  27.                         while(1)
  28.                                 {       
  29.         //                        printf ("%4d  %4d  %4d  %4d\r\n",AD_Value[0],AD_Value[1],AD_Value[2],AD_Value[3]);
  30. //                            delay_ms(100);       
  31.         LED0=0;  //灰度測試
  32.                                         ADC_CHANGE();
  33. //                                if(AD_Value[0]>2900)left1=1;//檢測到白線>3000 =1 檢測到綠線<3000=0
  34. //                                 else left1=0;
  35. //                                if(AD_Value[1]>2900)mid1=1;
  36. //                                 else mid1=0;
  37. //                                if(AD_Value[2]>2900)mid2=1;
  38. //                                 else mid2=0;
  39. //                                if(AD_Value[3]>2900)right1=1;
  40. //                                 else right1=0;
  41. //                                printf ("%4d  %4d  %4d  %4d\r\n",left1,mid1,mid2,right1);             


  42.                                         Go_STRAIGHT(80,80);
  43.                                   RUN();
  44.                          }

  45.                                  
  46.          
  47.          
  48. }
復(fù)制代碼

所有資料51hei提供下載:
基于灰度巡線的小車.7z (220.48 KB, 下載次數(shù): 93)






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