51单片机 DHT11+LCD1602温湿度显示 + Proteus仿真

51单片机 DHT11+LCD1602温湿度显示+ Proteus仿真


在这里插入图片描述

主程序代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <reg52.h>
#include <LCD1602.h>
#include <DTH11.h>
#include <intrins.h>

#define uchar unsigned char
#define uint unsigned int

uchar wendu [4];
uchar shidu [4];
uchar i;
int j;
void main()
{
//uchar i;
InitLcd1602();
LcdShowStr(2, 0, "Temp:");
LcdShowStr(2, 1, "Hum:");

while(1)
{
DHT11\_delay\_ms(100);
DHT11\_receive();
for(i=0;i<7;i++)
{
if(i<=2)
{
shidu[i]= rec_dat[i]; //读取湿度
}
if(i>=4)
{
wendu[i-4] = rec_dat[i];
}
}
LcdWaitReady();//准备LCD
LcdShowStr(8, 0,wendu);
LcdShowStr(10, 0,"\*C");
LcdShowStr(8, 1,shidu);//
LcdShowStr(10, 1,"%");

}
}


程序源码和仿真资源

1
2
3
链接:https://pan.baidu.com/s/1DhBGYuAtkmF68ZUNlwpasQ 
提取码:n7lx