当前位置:网站首页>基于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
边栏推荐
- 机器学习——模型优化
- SSL / TLS application example
- swin transformer 转 onnx
- rearrange 和 einsum 真的优雅吗
- excel实战应用案例100讲(八)-Excel的报表连接功能
- MySQL的安装与配置——详细教程
- WinForm scroll bar beautification
- 直观理解 torch.nn.Unfold
- 1.1 pytorch and neural network
- torch. mm() torch. sparse. mm() torch. bmm() torch. Mul () torch The difference between matmul()
猜你喜欢
Résolution du système
imx6ull-qemu 裸机教程1:GPIO,IOMUX,I2C
pth 转 onnx 时出现的 gather、unsqueeze 等算子
【点云系列】点云隐式表达相关论文概要
【点云系列】PnP-3D: A Plug-and-Play for 3D Point Clouds
Infrared sensor control switch
Chapter 8 generative deep learning
如何利用qemu搭建SOC protoype:80行代码实现一个Cortex M4 模拟器
【点云系列】DeepMapping: Unsupervised Map Estimation From Multiple Point Clouds
[point cloud series] pnp-3d: a plug and play for 3D point clouds
随机推荐
Unable to determine the device handle for GPU 0000:02:00.0: GPU is lost.
第1章 NumPy基础
【指标】Precision、Recall
Thanos. SH kill bully script, easily delete half of the files in the system at random
torch_geometric学习一,MessagePassing
主流 RTOS 评估
【点云系列】FoldingNet:Point Cloud Auto encoder via Deep Grid Deformation
【动态规划】不同的二叉搜索树
Gephi tutorial [1] installation
LPDDR4笔记
Pytorch model pruning example tutorial III. multi parameter and global pruning
【動態規劃】不同路徑2
PyTorch 10. 学习率
SSL / TLS application example
被 onnx.checker.check_model 检查出的常见错误
MySQL installation and configuration - detailed tutorial
Solution to slow compilation speed of Xcode
ECDSA 签名验证原理及C语言实现
PyTorch 18. torch.backends.cudnn
[point cloud series] sg-gan: advantageous self attention GCN for point cloud topological parts generation