|
|
個(gè)人原創(chuàng)設(shè)計(jì)作品,內(nèi)涵仿真,c與hex文件。c語(yǔ)言白癡,拒絕回答一切有關(guān)c的問(wèn)題。本設(shè)計(jì)是一款基于DS18B20傳感器的實(shí)時(shí)體溫測(cè)量報(bào)警儀,可以貼身舒適得放置在病人身上用以實(shí)時(shí)檢測(cè)體溫,然后將檢測(cè)的數(shù)據(jù)傳到AT89C51單片機(jī)進(jìn)行處理,再用LED屏幕以十進(jìn)制的方式進(jìn)行表出。同時(shí)還有個(gè)警報(bào)器模塊,當(dāng)病人體溫不正常到達(dá)臨界值時(shí)觸發(fā)警報(bào)用以提醒。程序具體表現(xiàn)為小于37℃時(shí),綠燈亮;大于37℃時(shí),蜂鳴器工作,紅燈。(51黑電子為原創(chuàng)出處,轉(zhuǎn)載請(qǐng)注明網(wǎng)址。)得到幫助的小伙伴給個(gè)有效回復(fù)撒,感謝!!!
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
Inked1_LI.jpg (1.45 MB, 下載次數(shù): 27)
下載附件
2020-5-16 14:03 上傳
單片機(jī)源程序如下:
- #include "reg51.h"
- #include "intrins.h"
- #define uchar unsigned char
- #define uint unsigned int
- #define out P0
- #define out1 P2
- #define out2 P3
- sbit DQ=P1^4;
- void delay5(uchar);
- void init_ds18b20(void);
- void writebyte(uchar);
- uchar retemp(void);
- void main (void)//主函數(shù)
- {
- uchar i,temp;
- delay5(1000);
- uchar[9]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
- uchar xiaoshudian=0x80;
- while(1)
- {
- temp=retemp();
- for(i=0;i<10;i++)//連續(xù)掃描數(shù)碼管10次
- {
- out=(uchar[temp/10]);
- out1=(uchar[temp%10]||xiaoshudian);
- }
- }
- }
- void delay5(uchar n)//延時(shí)5微妙函數(shù)
- {
- do
- { _nop_() ;
- _nop_() ;
- _nop_();
- n--;
- }
- while(n);
- }
- void init_ds18b20(void)//對(duì)18b20初始化函數(shù)
- {
- uchar x=0;
- DQ=0;
- delay5(120);
- DQ =1;
- delay5(16);
- delay5(80);
- }
- uchar readbyte(void)//函數(shù)功能:讀取1字節(jié)數(shù)據(jù)
- {
- uchar i=0;
- uchar date=0;
- for(i=8;i>0;i--)
- {
- DQ=0;
- delay5(1) ;
- DQ=1;//15微妙內(nèi)拉釋放總線
- date>>=1;
- if(DQ)
- date|=0x80;
- delay5(11);
- }
- return(date);}
- void writebyte (uchar dat)//寫(xiě)1b數(shù)據(jù)
- {
- uchar i=0;
- for(i=8;i>0;i--)
- {
- DQ=0;
- DQ =dat&0x01;//寫(xiě)"1"在15微妙內(nèi)拉低
- delay5(12);//寫(xiě)"0"拉低60微妙
- DQ=1;
- dat>>=1;
- delay5(5);
- }
- }
- uchar retemp(void)//讀取溫度函數(shù)
- {
- uchar a,b,tt;
- uint t;
- init_ds18b20();
- writebyte (0xCC);
- writebyte (0x44);
- init_ds18b20();
- writebyte(0xCC);
- writebyte(0xBE);
- a=readbyte();
- b=readbyte();
- t=b;
- t<<=8;
- t=t|a;
- tt=t*0.0625;
- return(tt);
- }
復(fù)制代碼
所有資料51hei提供下載 仿真,c及hex文件:
Desktop.rar
(35.64 KB, 下載次數(shù): 80)
2020-5-16 14:10 上傳
點(diǎn)擊文件名下載附件
仿真,c及hex文件 下載積分: 黑幣 -5
|
評(píng)分
-
查看全部評(píng)分
|