本设计:
基于STM32单片机智能跟随小车_红外遥控(程序+原理图+PCB+论文报告)
原理图:Altium Designer
程序编译器:keil 5
编程语言:C语言
编号C0021
资料下载
【腾讯文档】C0021 网盘链接
https://docs.qq.com/doc/DS1JjTFhXRHZXRnJj
功能描述:
1.以STM32F103RBT6为主控芯片,实现对小车的控制,使小车能够做出前进、后退、左转、右转等基本行驶动作,通过红外遥控控制小车工作模式的转换(自由行走避障模式、跟随模式)
2.利用压力传感器测重,放在小车上物品的重量在500g范围以内,可以跟随,如果超过范围,就停止不动,蜂鸣器响提示超重。
原理图(提供源文件):
PCB(提供源文件):
源程序(提供完整程序):
#include "led.h"
#include "delay.h"
#include "sys.h"
#include "usart.h"
#include "timer.h"
#include "adc.h"
#include "remote.h"
#include "hx711.h"
#include <string.h>
u8 Model=0; //????
u8 PWM_WIDTH=28;
u8 RunModel=0;
void Hw_Process()
{
u8 key;
key=Remote_Scan();
if(key)
{
Beep=1;
delay_ms(100); //???±300ms
Beep=0;
printf("rn?ì???ü??= %drn",key);
}
if(key==224)// - :???? ×???????±???????
{
RunModel=0;
}
else if(key==168)// - :???? ?ú??????
{
RunModel=1;
}
if(RunModel==0) //×???????±?????????????????
{
if(key==194)// ???? >||
{
Model=0;
printf("rn????rn");//
}
else if(key==34)//|<<
{
Model=4;
delay_ms(500); //???±300ms
Model=1;
printf("rn×órn");//
}
else if(key==2) //>>|
{
Model=3;
delay_ms(500); //???±300ms
Model=1;
printf("rn??rn");//
}
else if(key==162) //CH-
{
Model=1;
printf("rn?°??rn");//
}
else if(key==98) //CH
{
Model=2;
printf("rn?ó??rn");//
}
else if(key==48) // °????ü1
{
PWM_WIDTH=40;
printf("rn1??rn");//
}
else if(key==24) // °????ü2
{
PWM_WIDTH=35;
printf("rn2??rn");//
}
else if(key==122) // °????ü3
{
PWM_WIDTH=28;
printf("rn3??rn");//
}
}
}
int main(void)
{
u16 adcx;
unsigned long adtemp,adtemp1;
u16 Weight=0;
u16 temp1,temp2;
delay_init(); //???±??????????
LED_Init(); //????????LED??????????????
uart_init(9600);
//uart2_init(9600);
TIM3_Int_Init(10,5199);//10Khz??????????????????10??1ms ????????·??ò?°????
CH_SR04_Init();//???ù?¨?è????????
Remote_Init(); //?ì????????????
//ADInit();
Beep=1;
delay_ms(100); //???±300ms
Beep=0;
delay_ms(100); //???±300ms
Beep=1;
delay_ms(100); //???±300ms
Beep=0;
printf("rn-----------------------------------------------rn");//
adtemp=HX711_Read(); //???????¤????????AD??×??????????° ????????????·????????·???????ì????????×???
Model=0;
while(1)
{
Hw_Process();//?ì?????????í
if(RunModel==0) //×???????±????????????????? +???ù?¨±???
{
temp1=Senor_Using_Left()*10;
printf("rn×ó·??à??= %d cm",temp1);//?????ò????????????
temp2=Senor_Using_Right()*10;
printf("??·??à??= %d cmrn",temp2);//?????ò????????????
if((temp1<250||temp2<250)&&Model==1)//?°·???°????ü???è??±???
{
Model=0;
delay_ms(300); //???±300ms
Model=2;//?ó??
delay_ms(300); //???±300ms
Model=4;//??×?
delay_ms(300); //???±300ms
Model=1;//?°??
}
}
else if(RunModel==1) //????×????ú??????
{
adtemp1=HX711_Read();
if(adtemp1>adtemp) //?????ì????AD?ó???¤???±????????????·?????
{
Weight=(adtemp1-adtemp)*0.002388; //?ù???????÷????????????????????200g ???¨8494856?¨·???200g????????Ad????-8411097?¨??????·????±????AD??????
printf("rn ????=%d grn",Weight);
}
if(Weight>500)//?????????ó?? 500g ·??ù?÷±¨???????ú??
{
Beep=1;
delay_ms(300); //???±300ms
Beep=0;
delay_ms(300); //???±300ms
}
else
{
temp1=Senor_Using_Left()*10;
printf("rn×ó·??à??= %d cm",temp1);//?????ò????????????
temp2=Senor_Using_Right()*10;
printf("??·??à??= %d cmrn",temp2);//?????ò????????????
if((temp1<200)||(temp2<200)) // 200= 20cm ×ó??????·?????20cm
{
Model=0;//????
}
else if((temp1>1000)&&(temp2>1000))
{
printf("rn????rn");
Model=0;//
}
else if((temp1<1000)&&(temp2<1000))
{
printf("rn?°??rn");
Model=1;//
delay_ms(300); //???±300ms
if(temp1>temp2) //???÷???± ???????·?à??????×ó???????????ò??????
{
Model=3;//??×?
printf("rn??×?rn");
delay_ms(200); //???±300ms
//
}
else if(temp2>temp1)//???÷???± ???????·?à???????????????????ò×ó????
{
Model=4;//×ó×?
printf("rn×ó×?rn");
delay_ms(200); //???±300ms
}
}
Model=0;//
}
}
}
}
论文报告:
全部资料如下: