当前位置:网站首页>Hc-sr04 ultrasonic module driven by 51 single chip microcomputer (LCD1602 display)
Hc-sr04 ultrasonic module driven by 51 single chip microcomputer (LCD1602 display)
2022-07-20 07:56:00 【Youxin Electronics】
be based on 51 Single chip drive HC-SR04 Ultrasonic module (LCD1602 Show )
One 、 The basic parameters
HC- SR04+ It is a wide voltage ultrasonic ranging module . The overall dimensions and software of the module are the same as those of the old version
HC- SR04 Fully compatible with ; It can be compared with the old version HC SR04 Seamless switching . As low as 3V Low operating voltage ,
Make it relate to 3.3V Powered by electricity MCU It can be connected directly .
characteristic
Detection angle : <15°
Industrial grade MCU, working temperature :-20C~80C
Detection distance :5V:2cm-- 450cm;3.3V: 2cm–400cm
Wide voltage operation : 3V-5.5V And HC SR04 Software and hardware dimensions are fully compatible
plate . Upper wiring mode ,VCC、trig ( Control terminal )、echo( The receiver )、out( Empty feet ,GND).
Be careful : The module should be plugged into the circuit board before being powered on , Avoid high-level maloperation , If it does ,
Power on again to solve .
Two 、 Communication timing
3、 ... and 、 Part of the code shows
//HC-SR04 Wiring definitions
sbit INPUT = P1^2; // Echo receiving port
sbit OUTPUT = P1^3; // Ultrasonic trigger port
//LCD1602 Wiring definitions
//D0-D7----------P0
sbit rs = P0^7;
sbit rw = P0^6;
sbit lcden = P0^5;
/******************************************************************************/
/* The name of the function : main */
/* Function description : The main function */
/* Input parameters : nothing */
/* Parameters to describe : nothing */
/* Return value : nothing */
/******************************************************************************/
void main(void)
{
rw = 0;
initLCD();
Init_MCU();
Init_Parameter();
display_char(table,0x00);
display_char(table0,0x40);
Delay_xMs(30000);
display_char(table2,0x00);
display_char(table1,0x40);
while(1)
{
Trig_SuperSonic(); // Trigger ultrasonic emission
while(INPUT == 0) // Waiting for echo
{
;
}
Measure_Distance(); // Calculate the pulse width and convert it to distance
display_char(table3,0x40);
display(distance,0x49); // Show the distance
Init_Parameter(); // Parameter reinitialization
delayt(100); // Time delay , There must be at least 10ms interval
}
}
Four 、 The actual effect
summary
1、 Power supply 3.3V,5V All possible , Try not to supply more than 5V, No less than 3.3V
2、 The measured distance is the plane distance , The error of slope measurement will be particularly large
3、 The measuring angle is 15 Within degrees , Other objects blocking the measurement range will also affect the measurement results
If you need a complete project, you can leave a message below
边栏推荐
- C语言_字符串比较函数strcmp的使用及实现
- astgo短信插件安装说明
- 一篇文章掌握Mysql
- Flask框架——蓝图、flask-script
- [transfer] pyhton__ pycache__ Generation and function of folders
- js之数组,对象,类数组对象
- Summary of nodejs related issues (Part 1)
- About html: how to connect HTML to MySQL, whether the database should be done first or at the end of the database
- 【玩物立志-scratch少儿编程】骑上小摩托(动态背景+摄像头控制操作)
- Problems encountered in execve execution - resolved
猜你喜欢
C语言_字符串比较函数strcmp的使用及实现
Why do everyone want to enter the IT Internet industry?
ETCD数据库源码分析——EtcdServer run apply流程
一篇文章让你彻底搞懂关于性能测试常见术语的定义
ETCD数据库源码分析——ServerV2接口实现
execve 执行遇到的问题-已解决
视觉上位系统设计开发(halcon-winform)-7.license
Flask send_ Absolute path traversal caused by file function
Kalman filter ultrasonic ranging
WinForm layout and control adaptive resolution and prevention of dislocation
随机推荐
为什么大家都想进入IT互联网行业?
Namespace and module of TS
TensorFlow 2 详解(tf生态系统、安装、内务管理、基本操作)
【DEVOPS】DevOps推进过程中的一些最佳实践
A decorrelation sub domain adaptive framework based on weak pseudo supervision for cross domain land use classification
new投票
Etcd database source code analysis -- ServerV2 interface implementation
Review in the fifth week
社交电商模式前期应该怎么选?泰山众筹
[simulation] matrix counting (FWT)
Mysql 面向企业级开发(一)
Kalman filter ultrasonic ranging
不知道 MySQL 咋学?刷完牛客这 50 道题就够了!(第二篇)
Programmer social death moment 3.0
What direction can I develop in learning UI design? How to learn?
C语言编程题:(C语言)分糖果 通俗易懂
PHREEQC modeling and typical case analysis [reverse "compilation", "playful" post-processing technology, gibbsstudio and phreeplo methods]
Huawei 14 days Hongmeng equipment development practical notes I
Tkinter模块GUI图形化编程实战(八)——中国象棋(含超详解及完整源码、完整程序免费下载链接)
【模拟赛】矩阵计数(FWT)