久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 6132|回復: 2
打印 上一主題 下一主題
收起左側

stm32智能小車超聲波避障實驗(有舵機)源碼

  [復制鏈接]
跳轉到指定樓層
樓主
ID:297748 發表于 2018-10-24 21:08 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
這是一個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)


評分

參與人數 2黑幣 +60 收起 理由
qxc548542 + 10 共享資料的黑幣獎勵!
admin + 50 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏4 分享淘帖 頂1 踩
回復

使用道具 舉報

沙發
ID:423055 發表于 2018-11-8 16:02 | 只看該作者
不錯的資源
回復

使用道具 舉報

板凳
ID:1022994 發表于 2022-10-23 10:33 | 只看該作者
有原理圖嗎
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 免费三级黄 | 国产精品欧美一区二区 | 日产精品久久久一区二区福利 | 精品一区二区三区在线观看 | 国产精品99精品久久免费 | 国产成人午夜精品影院游乐网 | 天天摸天天看 | 久久久久亚洲精品 | 久草热视频 | 成人一区二区三区在线观看 | 久久久国产一区二区三区四区小说 | 成年人黄色一级毛片 | 羞羞视频网页 | 国产精品资源在线观看 | 成年男女免费视频网站 | 在线看无码的免费网站 | 亚洲成人免费 | 欧美日韩国产精品一区二区 | 日韩在线视频一区 | 亚洲激情自拍偷拍 | 久久久久久久国产 | 久热国产精品视频 | 亚洲资源在线 | 国产精品久久精品 | 国产91丝袜在线18 | 欧美精品在线视频 | 欧美v免费| 伊人超碰| 99亚洲综合 | 久久精品99久久 | 中文字幕一区二区三区日韩精品 | 国产在线91| aaaaaaa片毛片免费观看 | 福利视频网址 | 久久久噜噜噜久久中文字幕色伊伊 | 国产在线一区二区三区 | 久久人人网 | 一级免费毛片 | 影音先锋中文字幕在线观看 | 日韩av一区二区在线观看 | 欧美精品久久久久久久久久 |