




已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
/项目:数码管温度显示器/编写:LGY/功能:数码管显示温度#includereg52.h#includeintrins.h#define uchar unsigned char#define uint unsigned int/*位定义*/sbit RX =P30;sbit TX =P31;sbit RX_TX_con =P32;/sbit Fre_check =P35;sbit DQ =P35;sbit SDA =P36;sbit SCL =P37;sbit LED_1 =P02;sbit LED_2 =P00;sbit LED_3 =P01;sbit LED_4 =P03;unsigned char a1,a2,a3,a4;unsigned int temper;unsigned char code displaycode= / 0 1 2 3 4 5 6 7 8 9 0x28, 0xee, 0x32, 0xa2, 0xe4, 0xa1, 0x21, 0xea, 0x20, 0xa0, ;unsigned char code displaycode1= / 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 0x08, 0xce, 0x12, 0x82, 0xc4, 0x81, 0x01, 0xca, 0x00, 0x80, ;void INT() P0=0xff; P1=0xff; P2=0; P3=0; DQ=1; / Fre_check=1; void Delay(uint x) uint a,b; for(a=x;a0;a-) for(b=110;b0;b-);/*void Delay1(uint x,uchar y)uint i;uchar j;for(i=x;i0;i-);for(j=y;j0;j-);void reset()unsigned char st=1;Fre_check=1;/_nop_();/_nop_();while(st)Fre_check=0;Delay1(70,30);Fre_check=1;Delay1(4,4);if(Fre_check=1) st=1;else st=0;Delay1(50,10);void write_byte(unsigned char date)unsigned char temp,i;Fre_check=1;/_nop_();/_nop_();for(i=8;i0;i-) temp=date&0x01;Fre_check=0; /Delay1(1);_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();if(temp=1) Fre_check=1;Delay1(2,2);Fre_check=1;date=date1;unsigned char read_byte()unsigned char i,date;static bit j;for(i=8;i0;i-)date=date1;Fre_check=1;_nop_();_nop_();Fre_check=0;_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();Fre_check=1;_nop_();_nop_();_nop_();_nop_();j=Fre_check;if(j=1) date=date|0x08;Delay1(1,1);return (date);*/void delay1(int b)int s;for (s = 0; s b; s+);unsigned char ow_reset(void)unsigned char presence;DQ = 0; /pull DQ line lowdelay1(29); / leave it low for 480sDQ = 1; / allow line to return highdelay1(3); / wait for presencepresence = DQ; / get presence signaldelay1(25); / wait for end of timeslotreturn(presence); / presence signal returned / presence = 0, no part = 1unsigned char read_bit(void)unsigned char i;DQ = 0; / pull DQ low to start timeslotDQ = 1; / then return highfor (i = 0; i 3; i+); / delay 15s fromstart of timeslotreturn(DQ); / return value of DQ linevoid write_bit(char bitval)DQ = 0; / pull DQ low to start timeslotif(bitval=1) DQ =1; / return DQ high if write 1delay1(5);/ hold value for remainder of timeslotDQ = 1;/ Delay provides 16s per loop, plus 24s/Therefore, delay(5) = 104sunsigned char read_byte(void)unsigned char i;unsigned char value = 0;for (i = 0; i 8; i+)if(read_bit() value=value|0x01i;/ reads byte in, one byte at a time and then/ shifts it leftdelay1(6); / wait for rest of timeslot return(value);void write_byte(char val)unsigned char i;unsigned char temp;for (i = 0; i i; / shifts val right i spacestemp &= 0x01; / copy that bit to tempwrite_bit(temp); / write bit in temp intodelay1(5);void DisplayLed(uchar num1,uchar num2,uchar num3,uchar num4) LED_1=0;LED_2=1;LED_3=1;LED_4=1;P1=displaycodenum1;Delay(3); LED_1=1;LED_2=0;LED_3=1;LED_4=1;P1=displaycode1num2;Delay(3); LED_1=1;LED_2=1;LED_3=0;LED_4=1;P1=displaycodenum3;Delay(3); LED_1=1;LED_2=1;LED_3=1;LED_4=0;P1=displaycodenum4;Delay(3);void Get_tem()unsigned char tem1,tem2,num;float aaa;int temper;ow_reset(); /复位write_byte(0xCC);/跳过ROMwrite_byte(0x44);/温度转换for(num=1000;num0;num-) DisplayLed(a1,a2,a3,a4);ow_reset();write_byte(0xCC);write_byte(0xBE);tem1=read_byte();tem2=
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年度村后备干部选拔考试复习资料(含答案)
- 2025智能设备代理合同范本
- 德阳党校招聘考试试卷及答案
- 出入境工作人员安全培训课件
- 出入仓安全生产培训课件
- 大一体育课桥牌考试题及答案
- “粮食银行”诞生记
- 冲床安全操作规程
- 2025凭样品购销合同
- 冰雪路面安全驾驶培训课件
- 水稻全程机械化栽培技术
- 北京师大附中市级名校2026届中考适应性考试语文试题含解析
- 2025年秋季学期初中学校全面工作安排(含各周重点工作安排)
- 2025年山西省教师职称考试(理论知识)复习题及答案(新课标)-山西教师
- 心理学基础(第2版) 课件 第2章 心理发展
- 2025年小学语文教师招聘考试测试卷及参考答案(共三套)
- 电气设备维护与检测收费标准
- 2025年美团民宿违规试题
- 系统性红斑狼疮眼部表现
- 药物多靶点联合治疗-洞察及研究
- 海洋旅游特色项目案例集
评论
0/150
提交评论