#include <DHT.h>
#define DHTPIN 4
#define led1 8
#define led2 9
#define led3 10
#define led4 11
#define led5 12
#define DHTTYPE DHT22 
DHT dht(DHTPIN, DHTTYPE);
#include <Wire.h>
#include  <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() 
{
    pinMode(led1, OUTPUT);
    pinMode(led2, OUTPUT);
    pinMode(led3, OUTPUT);
    pinMode(led4, OUTPUT);
    pinMode(led5, OUTPUT);
  lcd.init();
  lcd.backlight();
  lcd.print("Rachaporn");
  lcd.setCursor(0, 1);
  lcd.print("t: ");
   lcd.setCursor(11, 1);
  lcd.print("h: ");
  Serial.begin(9600);
  Serial.println("DHTxx test!");
  dht.begin();

}
void loop() 
{
 delay(3000);
 float h = dht.readHumidity();
 float t = dht.readTemperature();
 if (isnan(h) || isnan(t)) 
 {
 Serial.println("Failed to read from DHT sensor!");
 return;
 }
 Serial.print("Humidity: ");
 Serial.print(h,0);
 Serial.print("%\t   ");
  lcd.setCursor(13, 1);
  lcd.print(h, 0);
  lcd.print("%\t   ");

 Serial.print(" Temperature: ");
 Serial.print(t,1);
 Serial.println("  C ");
  lcd.setCursor(2, 1);
  lcd.print(t, 1);
  lcd.print((char)223);
  lcd.print("c   ");
   if ( t > 5.9 && t <10.9 )
  {
    digitalWrite(led1, 1);
    digitalWrite(led2, 0);
    digitalWrite(led3, 0);
    digitalWrite(led4, 0);
    digitalWrite(led5, 0);
  }
  else if( t > 11.9 && t <25.9 )
  {
    digitalWrite(led1, 0);
    digitalWrite(led2, 1);
    digitalWrite(led3, 0);
    digitalWrite(led4, 0);
    digitalWrite(led5, 0);
  }
else if( t > 26.9 && t <35.9 )
  {
    digitalWrite(led1, 0);
    digitalWrite(led2, 0);
    digitalWrite(led3, 1);
    digitalWrite(led4, 0);
    digitalWrite(led5, 0);
  }
else if( t > 36.9 && t <40.9 )
  {
    digitalWrite(led1, 0);
    digitalWrite(led2, 0);
    digitalWrite(led3, 0);
    digitalWrite(led4, 1);
    digitalWrite(led5, 0);
  }
 else if( t > 50.9 && t <60.9 )
  {
    digitalWrite(led1, 0);
    digitalWrite(led2, 0);
    digitalWrite(led3, 0);
    digitalWrite(led4, 0);
    digitalWrite(led5, 1);
  }
}