当前位置:网站首页>Ultrasonic distance meter based on 51 single chip microcomputer
Ultrasonic distance meter based on 51 single chip microcomputer
2022-07-04 14:28:00 【toyjis】
The project is based on HC-SR04 Range finder of ultrasonic sensor , Use digital tube to display distance . The ranging range is 2cm-400cm, Use timer 0 Interrupt setting the sensor measurement frequency , Every time 200ms Refresh the data once .
HC-SR04 It is a common ultrasonic sensor , It is often used in the ranging of smart cars , Avoiding obstacles , Blind crutches and other fields ; This module directly integrates the ultrasonic transmitter 、 Receiver and control circuit , You can work directly by plugging it in , There is no need to connect the drive circuit .
HC-SR04 How it works :
1、 Use a pin of the MCU to send at least 10us High level TTL Pulse signal to module Trig Pin , Used to trigger the operation of the module ( The code is embodied as the start ranging function ).
2、 After the module detects the trigger signal , Will automatically send 8 individual 40khz The square wave , Then automatically switch to monitoring mode , Monitor whether there is signal return .
3、 If a signal returns , By module Echo The pin will output a high level , The duration of the high level is the time from the ultrasonic wave is emitted to the time it returns ( The code is embodied in the function of getting distance ).
This design does not use a simple delay function , Instead, the timer interrupt is used to control the frequency of ranging , This ensures that the sensor has enough time to receive data 、 Processing data .
The simulation diagram of the system is as follows :
It's still drawn PCB Territory , This drawing is for in-line devices PCB, The patch device version will be added later , In this way, it can be made into a small range finder .

Part of the code is shown below , Code according to HC-SR04 Instructions for writing
int getdistance(void)
{
start();
while(!ECHO);
TR1=1;
while(ECHO);
TR1=0;
time=TH1*256+TL1;
TH1=0;
TL1=0;
s=(time*1.7)/100+1; // Measured cm
if(flag==1||(s>700))
{
flag=0;
s=0;
return s;
}
return s;
}
void main()
{
init();
while(1)
{
display(distance);
}
}
** Resources include :keilC The language code +Proteus Simulation schematic +ad Schematic diagram PCB+ Product specification **
边栏推荐
- Supprimer les lettres dupliquées [avidité + pile monotone (maintenir la séquence monotone avec un tableau + Len)]
- Leetcode 61: 旋转链表
- 利用Shap值进行异常值检测
- Fs4059c is a 5V input boost charging 12.6v1.2a. Inputting a small current to three lithium battery charging chips will not pull it dead. The temperature is 60 ° and 1000-1100ma is recommended
- Scratch Castle Adventure Electronic Society graphical programming scratch grade examination level 3 true questions and answers analysis June 2022
- 聊聊保证线程安全的 10 个小技巧
- Chapter 16 string localization and message Dictionary (2)
- Why should Base64 encoding be used for image transmission
- 2022游戏出海实用发行策略
- R language uses the DOTPLOT function of epidisplay package to visualize the frequency of data points in different intervals in the form of point graph, and uses the by parameter to specify the groupin
猜你喜欢
![去除重複字母[貪心+單調棧(用數組+len來維持單調序列)]](/img/af/a1dcba6f45eb4ccc668cd04a662e9c.png)
去除重複字母[貪心+單調棧(用數組+len來維持單調序列)]

STM32F1与STM32CubeIDE编程实例-MAX7219驱动8位7段数码管(基于GPIO)

The implementation of OSD on rk1126 platform supports color translucency and multi-channel support for Chinese

统计php程序运行时间及设置PHP最长运行时间

Innovation and development of independent industrial software

按照功能对Boost库进行分类

nowcoder重排链表

Vscode common plug-ins summary

Excel quickly merges multiple rows of data

Nowcoder reverse linked list
随机推荐
实时数据仓库
R language uses dplyr package group_ The by function and the summarize function calculate the mean and standard deviation of the target variables based on the grouped variables
Ml: introduction, principle, use method and detailed introduction of classic cases of snap value
Real time data warehouse
One architecture to complete all tasks - transformer architecture is unifying the AI Jianghu on its own
数据中台概念
R语言dplyr包summarise_if函数计算dataframe数据中所有数值数据列的均值和中位数、基于条件进行数据汇总分析(Summarize all Numeric Variables)
Abnormal value detection using shap value
sql优化之explain
聊聊保证线程安全的 10 个小技巧
Sqlserver functions, creation and use of stored procedures
Some problems and ideas of data embedding point
NowCoder 反转链表
RK1126平台OSD的实现支持颜色半透明度多通道支持中文
实战解惑 | OpenCV中如何提取不规则ROI区域
去除重複字母[貪心+單調棧(用數組+len來維持單調序列)]
ViewModel 初体验
Oppo find N2 product form first exposure: supplement all short boards
codeforce:C. Sum of Substrings【边界处理 + 贡献思维 + 灵光一现】
MATLAB中tiledlayout函数使用