|
- ******************************************
- 名稱:室內(nèi)環(huán)境監(jiān)測(cè)系統(tǒng)
- 功能:利用DHT11進(jìn)行溫濕度的測(cè)量,并實(shí)時(shí)顯示在LCD1602
- 連接方式:
- DHT11: VDD 供電 3-5.5VDC
- DATA 串行數(shù)據(jù),單總線----P1^0口
- NC 空腳,請(qǐng)懸空
- GND 接地,電源負(fù)極
-
- LCD: 1、GND-電源地
- 2、VCC-+5V
- 3、V0-對(duì)比度調(diào)整(接地或者正極)
- 4、RS-寄存器選擇,高電平時(shí)候選擇數(shù)據(jù)寄存器,低電平時(shí)選擇指令寄存器(第四腳)-----P2^0
- 5、RW-讀寫信號(hào)線,高電平時(shí)進(jìn)行讀操作,低電平時(shí)進(jìn)行寫操作(第五腳)----P2^1
- 6、E/EN-使能端,高電平時(shí)讀取信息,負(fù)跳變時(shí)執(zhí)行指令(第六腳)----P2^2
- 7-14、D0-D7-數(shù)據(jù)位-P0口八位
- 15、背光正極
- 16、背光負(fù)極
- Date: 2016-11-7
- ********************************************/
-
- # include <reg51.h>
- # include <intrins.h>
- #include "define.h"
- #include "delay.h"
- #include "lcd.h"
- #include "cl.h"
-
- uchar RH,TH;
- /*****主函數(shù)*****/
- void main()
-
- {
- /*初始化LCD*/
- lcd_init();
- while(1)
- {
- /*接收數(shù)據(jù)*/
- receive();
-
- /*LCD的第一行顯示(濕度) */
- display(0x00,'H');
-
- display(0x01,':');
-
- display(0x02,RH/10+0x30); /*0x30表示帶字庫的LCD1602中0x30的位置放有數(shù)字0
- RH/10+0x30即表示濕度的十位數(shù)字在字庫RH/10+0x30的位置處放著*/
-
- display(0x03,RH%10+0x30);
-
- display(0X04,'%');
-
- /*LCD的第二行顯示(溫度)*/
- display(0x40,'T');
-
- display(0x41,':');
-
- display(0x42,TH/10+0x30);
-
- display(0x43,TH%10+0x30);
-
- /*溫濕度單位轉(zhuǎn)換*/
- display(0x44,0xdf);
-
- display(0x45,0x43);
-
- }
- }
|
|