#include <LiquidCrystal.h>
#include <DHT.h>
#define DHTPIN 5
#define DHTTYPE DHT22
DHT dht = DHT(DHTPIN,DHTTYPE);
int ledPin = 13;
LiquidCrystal lcd(12,11,10,9,8,7);
void setup(){
lcd.begin(16,2);
lcd.print("Temperature is : ");
Serial.begin(9600);
dht.begin();
pinMode(ledPin,OUTPUT);
}
void loop(){
delay(2000);
float temp = dht.readTemperature();
if(isnan(temp)){
Serial.println("Failed to read from DHT sensor!");
return;
}
else{
if(temp>25){
digitalWrite(ledPin,HIGH);
}
else{
digitalWrite(ledPin, LOW);
}
Serial.print("Temperature: ");
Serial.print(temp);
Serial.println(" *C");
}
lcd.setCursor(0,1);
lcd.print(temp);
delay(0);
lcd.print(" *C ");
}