#include <DHT.h>
DHT dht (4, DHT22); // Pin DHT
// Enrico William A. Sihotang_A022008
void setup() {
pinMode (13, OUTPUT);
pinMode (12, OUTPUT);
pinMode (11, OUTPUT);
Serial.begin (9600);
dht.begin();
}
void loop(){
float kelembaban = dht.readHumidity();
float suhu = dht.readTemperature();
if (suhu<25){
digitalWrite(13, HIGH);
digitalWrite(12, LOW);
digitalWrite(11, LOW);
}
else if (25<suhu and suhu<50){
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
digitalWrite(11, LOW);
}
else if (suhu>50){
digitalWrite(13, LOW);
digitalWrite(12, LOW);
digitalWrite(11, HIGH);
}
Serial.print("kelembaban: ");
Serial.print(kelembaban);
Serial.print(" ");
Serial.print("suhu: ");
Serial.println(suhu);
delay (2000);
}