没有合适的资源?快使用搜索试试~ 我知道了~
超声波测距,51单片机和c8051单片机程序文件.doc
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 190 浏览量
2022-07-06
01:09:14
上传
评论
收藏 45KB DOC 举报
温馨提示
![preview](https://dl-preview.csdnimg.cn/85918695/0001-a6f1e44951ec1a7d569d3bf5c9b4924d_thumbnail.jpeg)
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
试读
15页
超声波测距,51单片机和c8051单片机程序文件.doc
资源推荐
资源详情
资源评论
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![](https://csdnimg.cn/release/download_crawler_static/85918695/bg1.jpg)
. . . .
1 / 15
C8051F410 单片机程序
//-----------------------------------------------------------------------------
-------
#include <c8051f410.h> // SFR declarations
#include <intrins.h>
#include <stdio.h>
#define uint unsigned int
#define uchar unsigned char
sbit Trig=P0^7;
sbit Echo=P0^6;
sbit lcden=P2^4;
sbit lcdrs=P2^5;
sbit sdi=P2^6;
sbit clk=P2^7;
unsigned long s;
bit flag =0;
unsigned char code table1[]=" Ce De Jv Li is ";
unsigned char code table2[]="Chao Chu fan Wei";
unsigned char code table3[]="JingQue:";
unsigned char table[8];
//-----------------------------------------------------------------------------
-------
// Function PROTOTYPES
//-----------------------------------------------------------------------------
-------
void PORT_Init (void);
void Oscillator_Init();
void write_595(unsigned char da);
void lcd_init(void);
void write_(unsigned char );
void write_data(unsigned char da);
void delay(unsigned int z);
void delaym(uchar i);
void delaym(uchar i)
{
while(i--);
}
//-----------------------------------------------------------------------------
-------
// MAIN Routine
//-----------------------------------------------------------------------------
-------
void main()
![](https://csdnimg.cn/release/download_crawler_static/85918695/bg2.jpg)
. . . .
2 / 15
{
uchar num;
PCA0MD &= ~0x40; //禁止看门狗
PORT_Init ();
Oscillator_Init(); //时钟初始化
lcd_init();
while(1)
{
TMOD=0x01;
//EA=1;
//IE=0x80; //开启总中断
//TR0=0;
TH0=0;
TL0=0;
//ET0=1; //允许 T0 中断
//IE=0x80; //开启总中断
Trig=1;
delaym(200);
Trig=0;
while(!Echo);
TR0=1; //开启计数
while(Echo); //当 RX 为 1 计数并等待
TR0=0; //关闭计数
s=(TH0*256+TL0)*0.17*4;
table[0]=s/1000+0x30;
table[1]=(s%1000)/100+0x30;
table[2]=(s%100)/10+0x30;
table[3]='.';
table[4]=s%10+0x30;
table[5]='c';
table[6]='m';
table[7]='*';
if(s>=7000||flag==1||s<5) //超出测量围
{
write_(0x80+0x40);
for(num=0;num<17;num++)
{
write_data(table2[num]);
delay(10);
}
}
else
![](https://csdnimg.cn/release/download_crawler_static/85918695/bg3.jpg)
. . . .
3 / 15
{
write_(0x80+0x48);
for(num=0;num<8;num++)
{
write_data(table[num]);
delay(10);
}
write_(0x80+0x40);
for(num=0;num<8;num++)
{
write_data(table3[num]);
delay(10);
}
}
delay(1000);
}
}
/******************************************************************************
*********
函数名称: void PORT_Init(void)
功能描述: 初始化 I/O
输入: 无
输出: 无
全局变量: XBR1
调用模块: 无
*******************************************************************************
********/
void PORT_Init (void)
{
P2MDOUT = 0xC0;
XBR1= 0x40; /*使能交叉开关和弱上拉*/
}
/******************************************************************************
*********
函数名称: void Oscillator_Init()
功能描述: 初始化 Oscillator,时钟为片时钟八分频 3.0625Mhz
输入: 无
输出: 无
全局变量: 无
调用模块: 无
*******************************************************************************
********/
void Oscillator_Init()
剩余14页未读,继续阅读
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/acfce43ffe2c41f996326bd927946824_yhsbzl.jpg!1)
智慧安全方案
- 粉丝: 3702
- 资源: 59万+
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- 以下是一些适用于英语六级作文的万能句型模板,涵盖了引言、正文和结论部分的各类表达方式.docx
- MATLAB中的非线性规划
- 进行C语言面试资格确认是招聘过程中一个重要的步骤,目的是确保候选人具备足够的C语言编程能力和知识.docx
- Java 轻量级的集群负载均衡设计
- 纹身师个人网站模板.jpg
- 在C语言中,连接两个字符串(即将一个字符串附加到另一个字符串的末尾)通常可以使用标准库中的 `strcat` 函数.docx
- 数据库管理工具:dbeaver-ce-23.1.1-stable.x86-64.rpm
- 以下是几个具体竞赛题目的详细解答,包括建模思路、方法和步骤 .docx
- 一份关于全国大学生建模大赛的相关教程!!
- 以下是关于计算机网络和现代通信组网的详细教程、案例和相关项目的推荐.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)