当前位置:网站首页>Obstacle avoidance sensor module (stm32f103c8t6)
Obstacle avoidance sensor module (stm32f103c8t6)
2022-06-24 19:23:00 【Me-Space】
This experiment prints the prompt through the serial port debugging assistant , And light up LED The lamp .
One 、 summary
1. brief introduction
The sensor module has strong adaptability to ambient light , It has a pair of infrared transmitting and receiving tubes , The transmitting tube emits infrared rays of a certain frequency , When the detection direction encounters an obstacle ( Reflecting surface ) when , The infrared ray is reflected back and received by the receiving tube , After being processed by the comparator circuit , The output indicator lights up , At the same time, the signal output interface outputs digital signals ( A low level signal ).
2. Parameter description
- When the module detects an obstacle ahead , The output indicator on the circuit board will be on , meanwhile OUT Port persistence Output low level signal , The module detects the distance 2-30cm, Detection angle 35 degree , The detection distance can be adjusted by potentiometer , Adjust the potentiometer clockwise , The detection distance will increase , Counter clockwise voltage regulator , The detection distance is reduced .
- Sensor active infrared reflection detection , Therefore, the reflectivity and shape of the target are the key to the detection distance . Among them, black The detection distance is small , Large white , Small area and small distance , Large area and large distance .
- Sensor module output port OUT It can be directly connected with MCU IO Just connect your mouth , You can also directly drive a 5v Relay .
- The comparator adopts LM393, Stable work .
- May adopt 3-5v The DC power supply supplies power to the module . When the power is on , The red power indicator is on .
- Unable to detect black objects
Two 、 Experimental materials
- Minimum system STM32F10SC8T6.
- Obstacle avoidance sensor module .
- There are several DuPont lines .
3、 ... and 、 Hardware connection
Module pin | GPIO |
---|---|
VCC | VCC |
GND | GND |
OUT | PA1 |
notes :0: Object detected ,1: No object detected
Four 、 Implement the program
- initialization
void Infrared_Pin_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;// Floating input
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_1;
GPIO_Init(GPIOA,&GPIO_InitStruct);
}
- data fetch
//0: Object detected
int Infrared_Value(void)
{
uint8_t infrared_val = 0;
infrared_val = GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_1);
return infrared_val;
}
- The main function
int main(void)
{
Sys_Delay_Init();
Infrared_Pin_Init();
Usart1_Pin_Init(115200);
printf(" Successful initialization \r\n");
Led_Init();
while(1)
{
if(!Infrared_Value())
{
printf(" Objects ahead \r\n");
GPIO_SetBits(GPIOA,GPIO_Pin_0);// Lighten up led The lamp
}
else
{
GPIO_ResetBits(GPIOA,GPIO_Pin_0);// close led The lamp
}
}
}
5、 ... and 、 Experimental results 
Complete procedures and relevant data :
link :https://pan.baidu.com/s/1WSxbwlZuh6QmhmGUC5YIsg
Extraction code :xlin
If there is any mistake, please point out , thank you !
边栏推荐
- How to deal with the problem that the Flink CDC reads MySQL in full and always reports this error
- Why are life science enterprises on the cloud in succession?
- 敏捷之道 | 敏捷开发真的过时了么?
- NFT质押流动性挖矿系统开发技术
- Technology implementation | Apache Doris cold and hot data storage (I)
- 60 divine vs Code plug-ins!!
- NFT pledge liquidity mining system development technology
- 我链接mysql 报这个错 是啥意思呀?
- ###脚本实现raid0自动化部署
- [leetcode] rotation series (array, matrix, linked list, function, string)
猜你喜欢
Technology implementation | Apache Doris cold and hot data storage (I)
Introduction and download of nine npp\gpp datasets
LabView之MQTT协议使用
R语言corrplot相关热图美化实例分析
Volcano devient l'ordonnanceur de lots par défaut Spark
对国产数据库厂商提几个关于SQL引擎的小需求
Unity移动端游戏性能优化简谱之 以引擎模块为划分的CPU耗时调优
60 个神级 VS Code 插件!!
R language 4.1.0 software installation package and installation tutorial
一文理解OpenStack网络
随机推荐
Volcano becomes spark default batch scheduler
Does version 2.2.0 support dynamic addition of MySQL synchronization tables
The sharp sword of API management -- eolink
Xiaodi class massive data processing business short chain platform
Example analysis of corrplot related heat map beautification in R language
Fabric ledger data block structure analysis (I): how to analyze the smart contract transaction data in the ledger
TKDE2022:基于知识增强采样的对话推荐系统
Multi segment curve temperature control FB (SCL program) of PLC function block series
flink-sql的kafka的这个设置,group-offsets,如果指定的groupid没有提
对国产数据库厂商提几个关于SQL引擎的小需求
敏捷之道 | 敏捷开发真的过时了么?
flink cdc全量读mysql老是报这个错怎么处理
Working for 6 years with a monthly salary of 3W and a history of striving for one PM
Ls common parameters
Make track map
Nokov motion capture system makes it possible for multi field cooperative UAV to build independently
模块五
Development of NFT dual currency pledge liquidity mining system
Volcano成Spark默认batch调度器
智能合约安全审计入门篇 —— delegatecall (2)