




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、精選優(yōu)質(zhì)文檔-傾情為你奉上/項(xiàng)目:數(shù)碼管溫度顯示器/編寫:LGY/功能:數(shù)碼管顯示溫度#include"reg52.h"#include"intrins.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;sb
2、it 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, 0x
3、ca, 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;a>0;a-) for(b=110;b>0;b-);/*void Delay1(uint x,uchar y)uint i;uchar j;for(i=x;i>0;i-);for(j=y;j>0;j-);void reset()unsigned char st=1;Fre_check=1;/_nop_();/_nop_();while(st)
4、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;i>0;i-) temp=date&0x01;Fre_check=0; /Delay1(1);_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_
5、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=date>>1;unsigned char read_byte()unsigned char i,date;static bit j;for(i=8;i>0;i-)date=date>>1;Fre_check=1;_nop_();_nop_();Fre_che
6、ck=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); / l
7、eave 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
8、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
9、 = 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|0x01<<i;/ reads byte in, one byte at a time and then/ shifts it leftdelay1(6); / wait for rest of times
10、lot return(value);void write_byte(char val)unsigned char i;unsigned char temp;for (i = 0; i < 8; i+) / writes byte, one bit at a timetemp = val>>i; / shifts val right i spacestemp &= 0x01; / copy that bit to tempwrite_bit(temp); / write bit in temp intodelay1(5);void DisplayLed(uchar nu
11、m1,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(); /復(fù)位write_byte(0xCC);/跳過ROMwrite_byte(0x44);/溫度轉(zhuǎn)換for(num=1000;num>0;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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 中國數(shù)字孿生技術(shù)行業(yè)發(fā)展運(yùn)行現(xiàn)狀及投資戰(zhàn)略規(guī)劃報(bào)告
- 廉租房行業(yè)市場風(fēng)險(xiǎn)投資及融資策略趨勢分析研究報(bào)告(2024-2030)
- 健康生活綠色無毒課件
- 2024年冷凍設(shè)備項(xiàng)目投資申請報(bào)告代可行性研究報(bào)告
- 蒙自市市管干部管理辦法
- 虹口區(qū)食品倉庫管理辦法
- 行政兼培訓(xùn)管理暫行辦法
- 西安市出租出借管理辦法
- 衡陽市街道建設(shè)管理辦法
- 襄垣縣經(jīng)營場所管理辦法
- 聚磷腈功能高分子材料的合成及應(yīng)用
- 中國鐵路總公司《鐵路技術(shù)管理規(guī)程》(高速鐵路部分)2014年7月
- 鈣加維生素Dppt課件(PPT 14頁)
- TRD深基坑止水帷幕施工方案(22頁)
- FZ∕T 63013-2021 滌綸長絲織帶
- 八少八素初試甄別試題
- 哈薩克斯坦共和國有限責(zé)任公司和補(bǔ)充責(zé)任公司法
- 企業(yè)組織架構(gòu)圖模板
- 藏醫(yī)院制劑中心建設(shè)項(xiàng)目建議書寫作模板-定制
- 鋼結(jié)構(gòu)舞臺施工方案
- 軸類零件加工ppt課件
評論
0/150
提交評論