#include <DHT.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
DHT dht(2,DHT22);
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
dht.begin();
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("WeatherDetector ");
lcd.setCursor(4,1);
lcd.print("SITA ");
delay(500);
}
void loop() {
float t=dht.readTemperature();
float h=dht.readHumidity();
Serial.print("Humidity:");
Serial.println(h);
if(t<0){
lcd.clear();
lcd.setCursor(0,1);
lcd.print("Temperature:");
lcd.setCursor(12,1);
lcd.print(t);
lcd.setCursor(2,0);
lcd.print("LEVEL 1");
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
delay(500);
}
else if(t>0 && t<40){
lcd.clear();
lcd.setCursor(2,0);
lcd.print("LEVEL 2");
lcd.setCursor(0,1);
lcd.print("Temperature:");
lcd.setCursor(12,1);
lcd.print(t);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
delay(500);
}
else{
lcd.clear();
lcd.setCursor(2,0);
lcd.print("LEVEL 3");
lcd.setCursor(0,1);
lcd.print("Temperature:");
lcd.setCursor(12,1);
lcd.print(t);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
delay(500);
}
}