#include <DHT.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C LCD(0X27,16,2);
const int DHTPIN=2;
const int DHTTYPE=22;
DHT dht(DHTPIN,DHTTYPE);
void setup() {
// put your setup code here, to run once:
pinMode(10, OUTPUT);
LCD.init();
LCD.backlight();
dht.begin();
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
float temp=dht.readTemperature();
int h=dht.readHumidity();
LCD.setCursor(0,0);
LCD.print("Temperature:");
LCD.print(temp);
LCD.scrollDisplayRight();
LCD.setCursor(0,1);
LCD.print("Humidity:");
LCD.println(h);
delay(250);
if(temp>=40 ||h>=80){
digitalWrite(10, HIGH);
}else{
digitalWrite(10,LOW);
}
}