你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

智能车超声波避障源码

[复制链接]
梦帝呱呱 发布时间:2018-6-29 14:50
基于stm32f1的智能小车超声波避障源码,仅供参考
#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);
                }
        }
}


7、ZYSTM32-A0 智能小车超声波避障实验(有舵机).zip

下载

7.49 MB, 下载次数: 21

收藏 1 评论2 发布时间:2018-6-29 14:50

举报

2个回答
mxl818 回答时间:2018-8-16 16:03:08
st币扣了也没下载,什么事
david69chen 回答时间:2018-9-26 11:21:49
好东西,感谢分享!!

所属标签

STM32团队

意法半导体微控制器和微处理器拥有广泛的产品线,包含低成本的8位单片机和基于ARM® Cortex®-M0、M0+、M3、M4、M33、M7及A7内核并具备丰富外设选择的32位微控制器及微处理器


最新内容

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
STM32N6 AI生态系统
STM32MCU,MPU高性能GUI
ST ACEPACK电源模块
意法半导体生物传感器
STM32Cube扩展软件包
关注我们
st-img 微信公众号
st-img 手机版