基于51單片機(jī)智能農(nóng)業(yè)大棚恒溫恒濕Proteus仿真(源碼+仿真+全套資料)
資料編號(hào):134
視頻講解:
功能介紹:
采用51單片機(jī)作為主控芯片,可以采集當(dāng)前的溫濕度,并且LCD1602顯示,可以通過按鍵設(shè)置溫濕度的上下閾值,當(dāng)超過此設(shè)置閾值,蜂鳴器進(jìn)行報(bào)警,并且繼電器啟動(dòng)相對應(yīng)的功能,比如低于溫度設(shè)置的最低值,開啟加溫,高于溫度設(shè)置的最高值,開啟降溫;,比如低于濕度設(shè)置的最低值,開啟加濕,高于濕度設(shè)置的最高值,開啟去濕,全套資料齊全:
部分程序展示示例:
//定義四個(gè)輸出端口sbitLed_jiashi=P3^6;//加濕sbitLed_qushi=P3^4;//去濕sbitLed_jiangwen=P3^2;//降溫sbitLed_shengwen=P3^3;//升溫//定義三個(gè)設(shè)置按鍵sbitKey_SET=P2^0;sbitKey_ADD=P2^1;sbitKey_SUB=P2^2;sbitKey_OK?=P2^3;//定義24C02數(shù)據(jù)口sbitSCL=P1^0;sbitSDA=P1^1;//定義DHT11數(shù)據(jù)口sbitDATA=P1^7;sbitbuzz=P3^5;//定義LCD1602端口sbitE=P1^3;//1602使能引腳//sbitRW=P2^6;//1602讀寫引腳?sbitRS=P1^2;//1602數(shù)據(jù)/命令選擇引腳//定義全局變量
/*sbitLed_jiashi=P1^4;//加濕sbitLed_qushi=P1^5;//去濕sbitLed_jiangwen=P1^6;//降溫sbitLed_shengwen=P1^7;//升溫//定義三個(gè)設(shè)置按鍵sbitKey_SET=P1^0;sbitKey_ADD=P1^1;sbitKey_SUB=P1^2;sbitKey_OK?=P1^3;//定義24C02數(shù)據(jù)口sbitSCL=P2^1;sbitSDA=P2^0;//定義DHT11數(shù)據(jù)口sbitDATA=P3^7;sbitbuzz=P3^2;
//定義LCD1602端口sbitE=P2^7;//1602使能引腳//sbitRW=P2^6;//1602讀寫引腳?sbitRS=P2^6;//1602數(shù)據(jù)/命令選擇引腳sbitRW=P2^5;?*/
ucharU8FLAG,U8temp,U8comdata,U8RH_data_H_temp,U8RH_data_L_temp,U8T_data_H_temp,U8T_data_L_temp,U8checkdata_temp;ucharU8RH_data_H,U8RH_data_L,U8T_data_H,U8T_data_L,U8checkdata;ucharMode,humidity,temperature;charTH,TL,HH,HL;bitbdataFlagStartRH,hot,cold,humid,dry,BJ,flag_1,flag_2;//flag_1溫度標(biāo)志是否發(fā)短信,flag_2標(biāo)志濕度報(bào)警是否發(fā)短信
#defineNULL0#defineRsBuf_N?120
unsignedcharidataRsBuf[RsBuf_N];?//定義串口接收數(shù)據(jù)緩沖區(qū)ucharRsPoint;unsignedchar?dianhuahaoma[12]="";
//定時(shí)器0初始化voidTimer0_Init(){?ET0=1;//允許定時(shí)器0中斷?TMOD=0x21;?//定時(shí)器工作方式選擇?TL0=0xFF;TH0=0x4B;//定時(shí)器賦予初值?TR0=1;//啟動(dòng)定時(shí)器}
//定時(shí)器0中斷voidTimer0_ISR(void)interrupt1using0{?ucharRHCounter;?TL0=0xFF;?TH0=0x4B;//定時(shí)器賦予初值?RHCounter++;?if(RHCounter==0&&BJ==1)?buzz=!buzz;?elseif(BJ==0)?buzz=1;?//每2秒鐘啟動(dòng)一次溫濕度轉(zhuǎn)換if(RHCounter>=40){FlagStartRH=1;RHCounter=0;}}