#include "DHTesp.h"


const int DHT_PIN = 15;
DHTesp dhtSensor;
float suhu = 0;
float kelembaban = 0;
#define LEDR = 13;
#define LEDY = 27;
#define LEDG = 14;
void setup() {
  Serial.begin(115200);
  pinMode(13,OUTPUT);
  pinMode(12,OUTPUT);
  pinMode(14,OUTPUT);

  dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
}

void loop() {
  TempAndHumidity  data = dhtSensor.getTempAndHumidity();
  suhu=data.temperature;
  kelembaban=data.humidity;

  Serial.print("Temp: ");
  Serial.print(suhu);
  Serial.println("C");
  Serial.print("Humidity: ");
  Serial.print(kelembaban);
  Serial.println("%");

   
 if (suhu < 15 ){
    Serial.println("DINGIN ");
    digitalWrite(14, HIGH);
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);
    delay(2000);
  }
  else if (suhu <=27){
    Serial.println("NORMAL ");
    digitalWrite(14, LOW);
    digitalWrite(12, HIGH);
    digitalWrite(13, LOW);
    delay(2000);
  }
  else if (suhu > 27){
    Serial.println("PANAS ");
    digitalWrite(14, LOW);
    digitalWrite(12, LOW);
    digitalWrite(13, HIGH);
    delay(2000);
     }
  else{}
  if (kelembaban < 10 ){
    Serial.println("KERING ");
    digitalWrite(14, HIGH);
    digitalWrite(12, LOW);
    digitalWrite(13, LOW);
    delay(2000);
  }
  else if (kelembaban <=40){
    Serial.println("NORMAL ");
    digitalWrite(14, LOW);
    digitalWrite(12, HIGH);
    digitalWrite(13, LOW);
    delay(2000);
  }
  else if (kelembaban > 40){
    Serial.println("AWAS BANJIR ");
    digitalWrite(14, LOW);
    digitalWrite(12, LOW);
    digitalWrite(13, HIGH);
    delay(2000);
   }
  else{}
}