#include <DHT.h>
DHT dht(4, DHT22);
void setup() {
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
Serial.begin(9600);
dht.begin();
}
void loop() {
float suhu = dht.readTemperature();
if(suhu<20 ) {
digitalWrite(13, HIGH);
delay(200);
digitalWrite(13, LOW);
}
if(suhu>=20 && suhu <=40) {
digitalWrite(12, HIGH);
delay(500);
digitalWrite(12, LOW);
}
if(suhu>=40) {
digitalWrite(11, HIGH);
delay(1000);
digitalWrite(11, LOW);
}
Serial.print("Suhu: ");
Serial.print(suhu);
Serial.println("°C");
delay(1000);
}