#include <LiquidCrystal_I2C.h>
#include <DHT.h>
#define DHTPIN 10
#define DHTTYPE DHT22
#define LEDMerah 8
#define LEDBiru 9
DHT dht (DHTPIN, DHT22);
LiquidCrystal_I2C lcd(0x27,20,4);
int chk;
float hum;
float temp;
void setup() {
Serial.begin(9600);
dht.begin();
lcd.init ();
lcd.setBacklight(HIGH);
pinMode(LEDMerah,OUTPUT);
pinMode(LEDBiru,OUTPUT);
}
void loop() {
if (temp<18){
digitalWrite(LEDBiru, HIGH);
digitalWrite(LEDMerah, LOW);
if (hum<50)
digitalWrite(LEDBiru, HIGH);
digitalWrite(LEDMerah, LOW);
}
if (temp>25){
digitalWrite(LEDBiru, LOW);
digitalWrite(LEDMerah, HIGH);
if (hum>80)
digitalWrite(LEDBiru, LOW);
digitalWrite(LEDMerah, HIGH);
}
hum = dht.readHumidity();
temp = dht.readTemperature();
lcd.init();
lcd.backlight();
lcd.setCursor(3, 0);
lcd.print("Papan Informasi");
// suhu
lcd.setCursor(0, 2);
lcd.print("Suhu :");
lcd.setCursor(13, 2);
lcd.print(temp);
lcd.setCursor(19, 2);
lcd.print("C");
// kelembaban
lcd.setCursor(0, 3);
lcd.print("Kelembaban :");
lcd.setCursor(13, 3);
lcd.print(hum);
lcd.setCursor(19, 3);
lcd.print("%");
//delay(500);
//lcd.clear();
}