当前位置:网站首页>基于51单片机的三路超声波测距系统(定时器方式测距)
基于51单片机的三路超声波测距系统(定时器方式测距)
2022-04-23 06:14:00 【锦官城外w】
功能说明:
基于51单片机的三路(可更多)HCSR04、US100(io模式)超声波测距代码
注意事项:
处理器:STC89C51/STC89C52
显示屏:LCD1602
超声波:HCSR04、US100(io模式)
预留按键任务接口方便用户使用
相关引脚连线中文注释:
#include<reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
//---定义lcd1602使用的IO口---//
#define LCD_DATA P0
sbit RS=P2^7;
sbit RW=P2^6;
sbit EN=P2^5;
//---定义 按键 使用的IO口---//
sbit key1=P1^5;
sbit key2=P1^6;
sbit key3=P1^7;
//---定义 led 使用的IO口---//
sbit led=P2^1;
//HCSR04/US100超声波接口
sbit Trig1 = P2^0;
sbit Echo1 = P2^1;
sbit Trig2 = P2^2;
sbit Echo2 = P2^3;
sbit Trig3 = P3^7;
sbit Echo3 = P3^6;
主函数程序:
void
main()
{
lcd_init(); //1602初始化
Timer_Init(); //初始化定时器
while(1) //循环读取 并更新数据显示
{
key_scan(); //扫描按键(预留)
get_distance(1); //计算超声波1距离
dis_str(0,0,"US1:");dis_shu(4,0,distance1); //超声波1距离显示
get_distance(2); //计算超声波2距离
dis_str(0,1,"US2:");dis_shu(4,1,distance2); //超声波2距离显示
get_distance(3); //计算超声波3距离
dis_str(9,1,"US3:");dis_shu(13,1,distance3);//超声波3距离显示
}
}
全部资料链接见评论区,有问题请留言~
作者:amusen
时间:2022.4
祝好!
版权声明
本文为[锦官城外w]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_41740659/article/details/124329198
边栏推荐
- Machine learning II: logistic regression classification based on Iris data set
- RISCV MMU 概述
- PyTorch 17. GPU并发
- 【点云系列】 A Rotation-Invariant Framework for Deep Point Cloud Analysis
- Face_ Recognition face detection
- Chapter 4 pytoch data processing toolbox
- 【点云系列】Neural Opacity Point Cloud(NOPC)
- ArcGIS license server administrator cannot start the workaround
- torch.where能否传递梯度
- MySQL installation and configuration - detailed tutorial
猜你喜欢

LPDDR4笔记

第3章 Pytorch神经网络工具箱

【点云系列】Fully-Convolutional geometric features
![Gephi tutorial [1] installation](/img/f7/a37be7ac1af3216b7491e500760ad6.png)
Gephi tutorial [1] installation

【点云系列】SO-Net:Self-Organizing Network for Point Cloud Analysis

FATFS FAT32学习小记

Face_ Recognition face detection

【點雲系列】SG-GAN: Adversarial Self-Attention GCN for Point Cloud Topological Parts Generation

UEFI学习01-ARM AARCH64编译、ArmPlatformPriPeiCore(SEC)

Résolution du système
随机推荐
Paddleocr image text extraction
rearrange 和 einsum 真的优雅吗
WinForm scroll bar beautification
Unable to determine the device handle for GPU 0000:02:00.0: GPU is lost.
【点云系列】Fully-Convolutional geometric features
SHA512/384 原理及C语言实现(附源码)
PyTorch 22. PyTorch常用代码段合集
【動態規劃】不同路徑2
Machine learning II: logistic regression classification based on Iris data set
Compression and acceleration technology of deep learning model (I): parameter pruning
【动态规划】不同路径2
[point cloud series] a rotation invariant framework for deep point cloud analysis
Chapter 2 pytoch foundation 1
[8] Assertion failed: dims.nbDims == 4 || dims.nbDims == 5
第8章 生成式深度学习
Mysql database installation and configuration details
Solution to slow compilation speed of Xcode
【技术规范】:如何写好技术文档?
【点云系列】Unsupervised Multi-Task Feature Learning on Point Clouds
RISCV MMU 概述