xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 24KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-06
  • 語言: 其他
  • 標簽: DHT11??

資源簡介

基于AT89S52的DHT11溫濕度自動檢測程序

資源截圖

代碼片段和文件信息

#include?
#include?
#include
#define??uchar?unsigned?char
#define??uint??unsigned?int
sbit?ds=P2^2;?????//溫度傳感器信號線
sbit?lcden=P1^6;
sbit?rs=P1^0;
sbit?wr=P1^5;
uint?temp;
float?f_temp;
void?delay(uint?z)//延時函數
{
uint?xy;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}

void?dsreset(void)????//18B20復位,初始化函數
{
??uint?i;
??ds=0;
??i=103;
??while(i>0)i--;
??ds=1;
??i=4;
??while(i>0)i--;
}

bit?tempreadbit(void)???//讀1位函數
{
???uint?i;
???bit?dat;
???ds=0;i++;??????????//i++?起延時作用
???ds=1;i++;i++;
???dat=ds;
???i=8;while(i>0)i--;
???return?(dat);
}

uchar?tempread(void)???//讀1個字節
{
??uchar?ijdat;
??dat=0;
??for(i=1;i<=8;i++)
??{
????j=tempreadbit();
????dat=(j<<7)|(dat>>1);???//讀出的數據最低位在最前面,這樣剛好一個字節在DAT里
??}
??return(dat);
}

void?tempwritebyte(uchar?dat)???//向18B20寫一個字節數據
{
??uint?i;
??uchar?j;
??bit?testb;
??for(j=1;j<=8;j++)
??{
????testb=dat&0x01;
????dat=dat>>1;
????if(testb)?????//寫?1
????{
??????ds=0;
??????i++;i++;
??????ds=1;
??????i=8;while(i>0)i--;
????}
????else
????{
??????ds=0;???????//寫?0
??????i=8;while(i>0)i--;
??????ds=1;
??????i++;i++;
????}

??}
}

void?tempchange(void)??//DS18B20?開始獲取溫度并轉換
{
??dsreset();
??delay(1);
??tempwritebyte(0xcc);??//?寫跳過讀ROM指令
??tempwritebyte(0x44);??//?寫溫度轉換指令
}

uint?get_temp()?????????//讀取寄存器中存儲的溫度數據
{
??uchar?ab;

??dsreset();
??delay(1);
??tempwritebyte(0xcc);
??tempwritebyte(0xbe);
??a=tempread();?????????//讀低8位
??b=tempread();?????????//讀高8位
??temp=b;
??temp<<=8;????????????//兩個字節組合為1個字
??temp=temp|a;
??f_temp=temp*0.0625;??????//溫度在寄存器中為12位?分辨率位0.0625°
??temp=f_temp*10+0.5;????//乘以10表示小數點后面只取1位,加0.5是四舍五入
??f_temp=f_temp+0.05;?
??return?temp;?????????//temp是整型
}
//液晶程序段
void?delayms(unsigned?int?xms)
{
unsigned?int?ij;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}

void?write_com(unsigned?char?com)//寫命令
{
rs=0;
wr=0;
P0=com;
delayms(5);
lcden=0;
lcden=1;
delayms(10);
lcden=0;
}

void?write_data(unsigned?char?dat)//寫數據
{
rs=1;
wr=0;
P0=dat;
delayms(5);
lcden=0;
lcden=1;
delayms(10);
lcden=0;
}

void?init_lcd()//液晶初始化
{
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
}

void?display(uint?temp)?//顯示程序
{
uchar?A1A2A2tA3ser;
ser=temp/10;?//分離出三位要顯示的數字
A1=temp/100;
A2t=temp%100;
A2=A2t/10;
A3=A2t%10;
write_com(0x80+6);
write_data(0x30+A1);
write_data(0x30+A2);
write_data(‘.‘);
write_data(0x30+A3);

}

void?main()
{
??init_lcd();
??while(1)
?{????
??????tempchange();
??get_temp();
??display(temp);
?}
}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-09-23?10:59??溫濕度檢測程序\
?????文件???????14114??2013-03-18?09:08??溫濕度檢測程序\DHT11
?????文件????????2823??2013-04-02?21:36??溫濕度檢測程序\DHT11.c
?????文件??????????42??2013-03-18?09:08??溫濕度檢測程序\DHT11.lnp
?????文件???????18249??2013-03-18?09:08??溫濕度檢測程序\DHT11.LST
?????文件???????19254??2013-03-18?09:08??溫濕度檢測程序\DHT11.M51
?????文件???????16547??2013-03-18?09:08??溫濕度檢測程序\DHT11.OBJ
?????文件????????1158??2013-03-18?09:09??溫濕度檢測程序\DHT11.Opt
?????文件?????????442??2013-03-18?09:09??溫濕度檢測程序\DHT11.plg
?????文件????????2104??2013-03-18?09:07??溫濕度檢測程序\DHT11.Uv2
?????文件????????1158??2013-03-18?09:07??溫濕度檢測程序\DHT11_Opt.Bak
?????文件????????2104??2013-03-16?15:51??溫濕度檢測程序\DHT11_Uv2.Bak

評論

共有 條評論