#include "DHTesp.h"

#define dhtPin 15
#define LED_MERAH 2
#define LED_KUNING 4
#define LED_HIJAU 5

DHTesp dhtSensor;


void setup() {
Serial.begin(115200);
dhtSensor.setup(dhtPin, DHTesp::DHT22);
pinMode(LED_MERAH, OUTPUT);
pinMode(LED_KUNING, OUTPUT);
pinMode(LED_HIJAU, OUTPUT);
}

void loop() {
float temp = dhtSensor.getTemperature();
if(temp > 24.5){
Serial.println("Suhu Panas : " + String(temp));
digitalWrite(LED_MERAH, HIGH);
digitalWrite(LED_KUNING, LOW);
digitalWrite(LED_HIJAU, LOW);
}
else if(temp < 20.5){
Serial.println("Suhu Dingin : " + String(temp));
digitalWrite(LED_MERAH, LOW);
digitalWrite(LED_KUNING, HIGH);
digitalWrite(LED_HIJAU, LOW);
}
else{
Serial.println("Temperature : " + String(temp));
digitalWrite(LED_MERAH, LOW);
digitalWrite(LED_KUNING, LOW);
digitalWrite(LED_HIJAU, HIGH);
}
delay(1000);
}