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

標題: stm32智能小車超聲波避障實驗(有舵機)源碼 [打印本頁]

作者: 小胖波波    時間: 2018-10-24 21:08
標題: stm32智能小車超聲波避障實驗(有舵機)源碼
這是一個stm32小車的避障程序,親測可行,歡迎大家下載

單片機源程序如下:
  1. #include "stm32f10x.h"
  2. #include "delay.h"
  3. #include "motor.h"
  4. #include "keysacn.h"
  5. #include "IRSEARCH.h"
  6. #include "IRAvoid.h"
  7. #include "usart.h"
  8. #include "UltrasonicWave.h"
  9. #include "timer.h"
  10. #include "Server.h"

  11. // 超聲波轉頭函數
  12. int front_detection()
  13. {

  14. //        ZYSTM32_brake(0);
  15.         SetJointAngle(90);
  16.         delay_ms(100);
  17.         return UltrasonicWave_StartMeasure();
  18. }
  19. int left_detection()
  20. {

  21. //        ZYSTM32_brake(0);
  22.         SetJointAngle(175);
  23.         delay_ms(300);
  24.         return UltrasonicWave_StartMeasure();
  25. }
  26. int right_detection()
  27. {

  28. //        ZYSTM32_brake(0);
  29.         SetJointAngle(5);
  30.         delay_ms(300);
  31.         return UltrasonicWave_StartMeasure();
  32. }
  33. //extern int U_temp;
  34. /*
  35. void ZYSTM32_run(int speed,int time);       //前進函數
  36. void ZYSTM32_brake(int time);               //剎車函數
  37. void ZYSTM32_Left(int speed,int time);      //左轉函數
  38. void ZYSTM32_Spin_Left(int speed,int time); //左旋轉函數
  39. void ZYSTM32_Right(int speed,int time);     //右轉函數
  40. void ZYSTM32_Spin_Right(int speed,int time);//右旋轉函數
  41. void ZYSTM32_back(int speed,int time);      //后退函數
  42. */

  43. int main(void)
  44. {       
  45.    int Q_temp,L_temp,R_temp;
  46.          delay_init();
  47.          KEY_Init();
  48.          IRSearchInit();
  49.          IRAvoidInit();
  50.    Timerx_Init(5000,7199);                //10Khz的計數頻率,計數到5000為500ms
  51.          UltrasonicWave_Configuration();        //對超聲波模塊初始化
  52.          uart_init(115200);
  53.          TIM4_PWM_Init(7199,0);                 //初始化PWM
  54.          TIM5_PWM_Init(9999,143);               //不分頻,PWM頻率=72*10^6/(9999+1)/(143+1)=50Hz         
  55.          ZYSTM32_brake(500);
  56.          keysacn();               
  57.         while(1)
  58.         {                 
  59.         //        Q_temp = front_detection();
  60.         //  printf("測到的距離值為:%d\n",Q_temp);
  61.                 Q_temp = front_detection();
  62.                 if(Q_temp<60 && Q_temp>0) //測量距離值       
  63.                 {
  64.                         ZYSTM32_brake(500);               
  65.                         ZYSTM32_back(60,500);       
  66.                         ZYSTM32_brake(1000);       
  67.                        
  68.                         L_temp=left_detection();//測量左邊障礙物的距離值
  69.                         delay_ms(500);
  70.                         R_temp=right_detection();//測量右邊障礙物的距離值
  71.                         delay_ms(500);
  72.                        
  73.                         if((L_temp < 60 ) &&( R_temp < 60 ))//當左右兩側均有障礙物靠的比較近
  74.                         {
  75.                                 ZYSTM32_Spin_Left(60,500);
  76.                         }                               
  77.       else if(L_temp > R_temp)
  78.                         {
  79.                                 ZYSTM32_Left(60,700);
  80.                                 ZYSTM32_brake(500);
  81.                         }       
  82.       else
  83.                         {
  84.                                 ZYSTM32_Right(60,700);
  85.                                 ZYSTM32_brake(500);                                       
  86.                         }                                                       
  87.                 }       
  88.                 else
  89.                 {
  90.                         ZYSTM32_run(60,10);
  91.                 }
  92.         }
  93. }
復制代碼

所有資料51hei提供下載:
stm32智能小車超聲波避障實驗(有舵機).rar (338.1 KB, 下載次數: 163)



作者: 啊杰啊啊啊    時間: 2018-11-8 16:02
不錯的資源
作者: curry30呀    時間: 2022-10-23 10:33
有原理圖嗎




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