#include <DHT.h>
DHT dht(7, DHT22);
float kelembapan;
float temperatur;
void setup() {
Serial.begin(9600);
pinMode(A5, INPUT);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
pinMode(6, INPUT);
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
dht.begin();
}
void loop() {
int moistVal = analogRead(A5);
if (moistVal < 500) {
digitalWrite(5, HIGH);
digitalWrite(4, LOW);
}
else {
digitalWrite(5, LOW);
digitalWrite(4, HIGH);
}
if (digitalRead(6) == HIGH){
digitalWrite(3, HIGH);
}
else{
digitalWrite(3, LOW);
}
kelembapan = dht.readHumidity(); temperatur = dht.readTemperature();
if(kelembapan >= 15.00 && kelembapan <= 25.00 && temperatur >= 32.00){
digitalWrite(2, HIGH);
}
else {
digitalWrite(2, LOW);
}
}