include Liquid Crystal h include dht h Liquid

  • Slides: 17
Download presentation

程式碼 #include <Liquid. Crystal. h> #include <dht. h> Liquid. Crystal lcd(12, 11, 5, 4,

程式碼 #include <Liquid. Crystal. h> #include <dht. h> Liquid. Crystal lcd(12, 11, 5, 4, 3, 2); dht DHT; #define DHT 22_PIN 7 //使用Liquid. Crystal Library //使用DHT Library //初始設定LCD顯示器的介面 //定義DHT 物件 //定義讀取資料的 Pin腳 const int button. Pin = 8; const int relay. Pin = 9; int relay. State = 0; //按鈕(pushbutton) //繼電器(Relay) //繼電器狀態 void setup() { lcd. begin(16, 2); //設定LCD有2列 16欄 Serial. begin(9600); pin. Mode(button. Pin, INPUT); //把 button. Pin 設置成 INPUT pin. Mode(relay. Pin, OUTPUT); //把 relay. Pin 設置成 OUTPUT } lcd. print("IW: "); //顯示室內溼度 lcd. print((float)DHT. humidity, 1); lcd. print("%"); lcd. set. Cursor(8, 0); lcd. print("IH: "); //顯示室內溫度 lcd. print((float)DHT. temperature, 1); lcd. print("C"); lcd. set. Cursor(0, 1); 2014/12/3 15

if ((wet < 300)&&(hot<35)) 空 { lcd. print(“WET: ”); lcd. print(“dry soil”); else if((wet>600)&&(hot>35))

if ((wet < 300)&&(hot<35)) 空 { lcd. print(“WET: ”); lcd. print(“dry soil”); else if((wet>600)&&(hot>35)) 空 { //當土壤溼度小於 300和 氣溫度小於 35度 //顯示土壤濕度 //顯示乾燥的土壤 //當土壤溼度大於 600和 氣溫度小於 35度 lcd. print(“WET: ”); //顯示土壤濕度 lcd. print(“in water”); //顯示土壤過濕 digital. Write(relay. Pin, relay. State); //讓繼電器作動, 切換開關 Serial. print("Relay status: "); //把繼電器的狀態印到 Serial Port Serial. println(relay. State); } break; case -1: lcd. print("Checksum error"); break; case -2: lcd. print("Time out error"); break; default: lcd. print("Unknown error"); break; } 2014/12/3 delay(1000); 16

參考文獻 逢甲大學自動控制 程學系。2010。 LCD溫溼度感測器。 網址: http: //www. auto. fcu. edu. tw/w. Site/publicf ile/Attachment/f 1278917850341.

參考文獻 逢甲大學自動控制 程學系。2010。 LCD溫溼度感測器。 網址: http: //www. auto. fcu. edu. tw/w. Site/publicf ile/Attachment/f 1278917850341. pdf。 上網日期: 2014 -05 -02 北台灣科學技術學院電機 程系。2011。 園藝自動澆水施肥裝置之研究。 網址: http: //lib. tpcu. edu. tw/ezfiles/28/1028/im g/142/3. pdf。 上網日期: 2014 -05 -02 2014/12/3 17