欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
stm32智能小車超聲波避障實驗(有舵機)源碼
[打印本頁]
作者:
小胖波波
時間:
2018-10-24 21:08
標題:
stm32智能小車超聲波避障實驗(有舵機)源碼
這是一個stm32小車的避障程序,親測可行,歡迎大家下載
單片機源程序如下:
#include "stm32f10x.h"
#include "delay.h"
#include "motor.h"
#include "keysacn.h"
#include "IRSEARCH.h"
#include "IRAvoid.h"
#include "usart.h"
#include "UltrasonicWave.h"
#include "timer.h"
#include "Server.h"
// 超聲波轉頭函數
int front_detection()
{
// ZYSTM32_brake(0);
SetJointAngle(90);
delay_ms(100);
return UltrasonicWave_StartMeasure();
}
int left_detection()
{
// ZYSTM32_brake(0);
SetJointAngle(175);
delay_ms(300);
return UltrasonicWave_StartMeasure();
}
int right_detection()
{
// ZYSTM32_brake(0);
SetJointAngle(5);
delay_ms(300);
return UltrasonicWave_StartMeasure();
}
//extern int U_temp;
/*
void ZYSTM32_run(int speed,int time); //前進函數
void ZYSTM32_brake(int time); //剎車函數
void ZYSTM32_Left(int speed,int time); //左轉函數
void ZYSTM32_Spin_Left(int speed,int time); //左旋轉函數
void ZYSTM32_Right(int speed,int time); //右轉函數
void ZYSTM32_Spin_Right(int speed,int time);//右旋轉函數
void ZYSTM32_back(int speed,int time); //后退函數
*/
int main(void)
{
int Q_temp,L_temp,R_temp;
delay_init();
KEY_Init();
IRSearchInit();
IRAvoidInit();
Timerx_Init(5000,7199); //10Khz的計數頻率,計數到5000為500ms
UltrasonicWave_Configuration(); //對超聲波模塊初始化
uart_init(115200);
TIM4_PWM_Init(7199,0); //初始化PWM
TIM5_PWM_Init(9999,143); //不分頻,PWM頻率=72*10^6/(9999+1)/(143+1)=50Hz
ZYSTM32_brake(500);
keysacn();
while(1)
{
// Q_temp = front_detection();
// printf("測到的距離值為:%d\n",Q_temp);
Q_temp = front_detection();
if(Q_temp<60 && Q_temp>0) //測量距離值
{
ZYSTM32_brake(500);
ZYSTM32_back(60,500);
ZYSTM32_brake(1000);
L_temp=left_detection();//測量左邊障礙物的距離值
delay_ms(500);
R_temp=right_detection();//測量右邊障礙物的距離值
delay_ms(500);
if((L_temp < 60 ) &&( R_temp < 60 ))//當左右兩側均有障礙物靠的比較近
{
ZYSTM32_Spin_Left(60,500);
}
else if(L_temp > R_temp)
{
ZYSTM32_Left(60,700);
ZYSTM32_brake(500);
}
else
{
ZYSTM32_Right(60,700);
ZYSTM32_brake(500);
}
}
else
{
ZYSTM32_run(60,10);
}
}
}
復制代碼
所有資料51hei提供下載:
stm32智能小車超聲波避障實驗(有舵機).rar
(338.1 KB, 下載次數: 163)
2018-10-25 01:02 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
作者:
啊杰啊啊啊
時間:
2018-11-8 16:02
不錯的資源
作者:
curry30呀
時間:
2022-10-23 10:33
有原理圖嗎
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1