基于单片机的温湿度计的设计

发布时间 : 星期二 文章基于单片机的温湿度计的设计更新完毕开始阅读

.

rs = 1 ; rw = 0 ; ep = 0 ; P1 = dat ; ep = 1 ; ep = 0 ; }

void lcd_init()// 初始化 { }

void display(uchar addr, uchar q)//在某一地址上显示一字节 { }

/************DHT11测试模块************/ void start()//开始信号 {

.

write_cmd(0x38) ; delay(1);

write_cmd(0x08) ; delay(1);

write_cmd(0x01) ; delay(1);

write_cmd(0x06) ; delay(1);

write_cmd(0x0c) ; delay(1);

delay(10) ; write_addr(addr) ; longdelay(2) ;

write_byte(q) ;

io=1; delay1(); io=0;

delay(20);//>18ms io=1;

.

}

delay1();//20-40us delay1(); delay1(); delay1(); delay1();

uchar receive_byte()//接收一个字节 { }

void receive()//接收数据 {

.

uchar i,temp,count; for(i=0;i<8;i++) { }

return data_byte;

count=2;

while((!io)&&count++)//等待50us低电平结束 temp=0;

delay1();delay1();delay1();delay1(); if(io==1)temp=1; count=2;

while((io)&&count++); if(count==1)break; data_byte<<=1; data_byte|=temp;

uchar T_H,T_L,R_H,R_L,check,num_check; uchar count; start();//开始信号 io=1;

if(!io)//读取DHT11响应信号 { count=2;

while((!io)&&count++);//DHT11高电平80us是否结束 count=2;

.

}

while((io)&&count++); R_H=receive_byte(); R_L=receive_byte(); T_H=receive_byte(); T_L=receive_byte(); check=receive_byte();

io=0; //拉低延时50us

delay1();delay1();delay1();delay1();delay1(); io=1;

num_check=R_H+R_L+T_H+T_L; if(num_check=check) { } }

RH=R_H; RL=R_L; TH=T_H; TL=T_L;

check=num_check;

/************主函数************/ void main() {

.

lcd_init(); delay(10); while(1) {

receive(); delay(100);

display(0x00,'R') ; display(0x01,':'); display(0x02,RH/10+0x30); display(0x03,RH+0x30); display(0x04,'%'); display(0x40,'T') ;

.

}

}

display(0x41,':'); display(0x42,TH/10+0x30); display(0x43,TH+0x30); display(0x44,0xdf); display(0x45,0x43);

/************结束************/

.

联系合同范文客服:xxxxx#qq.com(#替换为@)