#include "DHT.h"
int p=2;
int red=3;
int orange=6;
int green=8;  
DHT dht(p, DHT22);

void setup() {
  Serial.begin(115200);
  Serial.println(F("DHT22 example!"));
  dht.begin();
}

void loop() {
  float temp = dht.readTemperature();
  float humi = dht.readHumidity();

  // Check if any reads failed and exit early (to try again).
  if (isnan(temp) || isnan(humi)) 
  {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }
  digitalWrite(red, LOW);
  digitalWrite(green, LOW);
  digitalWrite(orange, LOW);

  Serial.print(F("Humidity: "));
  Serial.print(humi);
  Serial.print(F("%  Temperature: "));
  Serial.print(temp);
  Serial.println(F("°C "));
  if(temp>=40)
   digitalWrite(red,HIGH);
  else if(temp<=16)
    digitalWrite(green, HIGH);
  else
    digitalWrite(orange, HIGH);
  delay(1000);
}