- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
超声波hc-sr04显示(Ultrasonic hc-sr04 display)
超声波hc-sr04显示(Ultrasonic hc-sr04 display)
/ / ultrasonic module HC-SR04 display program
/ / crystal =8M
//MCU=STC10F04XE
//P0.0-P0.6 nixietube pin
//Trig = P1^0
//Echo = P3^2
#include reg52.h / / 52 includes a standard kernel header file
#define uchar unsigned char / / define convenient use
#define uint unsigned int
#define ulong unsigned long
//***********************************************
SFR CLK_DIV = 0x97; / / STC microcontroller definition, system clock frequency
/ / STC microcontroller IO port address set definition
SFR P0M1 = 0X93;
SFR P0M0 = 0X94;
SFR P1M1 = 0X91;
SFR P1M0 = 0X92;
SFR P2M1 = 0X95;
SFR P2M0 = 0X96;
//***********************************************
Sbit Trig = P1^0; / / pulse pin
Sbit Echo = P3^2; / / return pin
Sbit test = P1^1; / / test pin
Uchar code SEG7[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90}; / / 0-9 digital tube
Uint distance[4]; / / ranging receive buffer
Uchar Ge, Shi, Bai, temp, flag, outcomeH, outcomeL, I; / / custom register
Bit succeed_flag; / / measuring success
//******** function declaration
Void conversion (uint temp_data);
Void, delay_20us ();
//void, pai_xu ();
Void main (void) / main program
{uint, distance_data, a, b;
Uchar CONT_1;
CLK_DIV=0X03; / / the system clock is 1/8 crystal (pdf-45 pages)
P0M1 = 0; / / IO port will be set to a push-pull output
P1M1 = 0;
P2M1 = 0;
P0M0 = 0XFF;
P1M0 = 0XFF;
P2M0 = 0XFF;
I=0;
Flag=0;
Test =0;
Trig=0; / / the first low pulse input pin
TMOD=0x11; / / timer 0, timer 1, 16 ways of working
TR0=1; / / start timer 0
IT0=0; / / by the high level low level, trigger external interrupt
ET0=1; / / open the timer 0 interrupt
//ET1=1; / / open the timer 1 interrupt
EX0=0; / / close external interrupt
EA=1; / / open interrupt 0
While (1) / / program cycle
{
EA=0;
Trig=1;
Delay_20us ();
Trig=0; / / pulse of a 20us, the Trig pin
While (Echo==0); / / wait for the Echo pin high echo
Succeed_flag=0; / / clear measurement mark of success
EX0=1; / / open external interrupt
TH1=0; / / reset
您可能关注的文档
- 计算机专业数据结构试题732(Professional computer data structure test 732).doc
- 计算机专业数据结构试题5556(Professional computer data structure test 5556).doc
- 计算机专业数据结构试题7432(Professional computer data structure test 7432).doc
- 计算机专业数据结构试题7566(Professional computer data structure test 7566).doc
- 计算机专业数据结构试题5757(Professional computer data structure test 5757).doc
- 计算机专业数据结构试题7633(Professional computer data structure test 7633).doc
- 计算机专业数据结构试题7365(Professional computer data structure test 7365).doc
- 计算机专业数据结构试题5958(Professional computer data structure test 5958).doc
- 计算机专业数据结构试题7700(Professional computer data structure test 7700).doc
- 计算机专业数据结构试题7767(Professional computer data structure test 7767).doc
- 资源经济学试题a(Resource Economics questions a).doc
- 超声波探伤(Ultrasonic examination).doc
- 超声波无损探伤技术操作规程1(Ultrasonic non-destructive inspection technology procedures 1).doc
- 超声波流量计技术问题汇总(Summary of technical problems of ultrasonic flowmeter).doc
- 超声波测厚仪失真维修方法(The distortion of the maintenance method of ultrasonic thickness gauge).doc
- 超声波测距12864显示程序带语音播报(12864 ultrasonic ranging display program with voice broadcast).doc
- 超声波清洗机原理(The principle of ultrasonic cleaning machine).doc
- 超凡成就在于8小时之外(The extraordinary achievement is 8 hours).doc
- 超声波焊接机工作原理(The working principle of ultrasonic welding machine).doc
- 超声波清洗机超声波放大器的选择(Ultrasonic cleaning machine of ultrasonic Amplifier Selection).doc
最近下载
- 网课答案《日本近现代文学选读》超星尔雅答案2023章节答案.docx VIP
- 《统一多民族国家的巩固和发展》教学设计.docx VIP
- 2023年中考一次函数压轴题集锦含分析、超详细解析答案、点评.pdf VIP
- 影视作品联合出品合同.doc VIP
- 历年(2020-2024)全国高考数学真题分类(指数、对数、幂函数、函数图象、函数零点及函数模型)汇编(附答案).pdf VIP
- 开学第一课课件-中职中专入学教育主题班会.pptx VIP
- DBJ04_T490-2025 《海绵型建筑与小区建设技术标准》.pdf VIP
- 固体制剂车间多品种共线生产风险综合评估报告.doc VIP
- 疾控网络安全培训课件.pptx VIP
- 中小学班主任培训讲座讲稿.docx VIP
文档评论(0)