#include DHT.h #define DHTPIN 2 #define DHTTYPE DHT22 int H = 30 ; int T = 45 ; DHT dht (DHTPIN, DHTTYPE) ; void setup() { Serial.begin(9600) ; pinMode(7, OUTPUT) ; fan pinMode(6, OUTPUT) ; heater pinMode(5, OUTPUT) ; Blue pinMode(4, OUTPUT) ; Green pinMode(3, OUTPUT) ; Red dht.begin(); digitalWrite (7, LOW) ; switch off the fan digitalWrite (6, LOW) ; switch off the heater digitalWrite (5, LOW) ; switch off the blue digitalWrite (4, LOW) ; switch off the green digitalWrite (3, LOW) ; switch off the red } void loop() { delay(2000) ; float hf = dht.readHumidity () ; int hi = (int) hf; float tf = dht.readTemperature() ; int ti = (int) tf; float f = dht.readTemperature(true) ; if (ti T) { Serial.print(Temperature= ) ; Serial.println(ti) ; digitalWrite (7, HIGH) ; switch on the fan digitalWrite (6, HIGH) ; switch on the heater digitalWrite (3, HIGH) ; switch on the red digitalWrite (5, LOW) ; switch off the blue digitalWrite (4, LOW) ; switch off the green } else { Serial.print(Optimum Temperature) ; Serial.println(ti) ; digitalWrite (6, LOW) ; switch off the heater } if (hi H) { Serial.print(Humidity= ) ; Serial.println(hi); digitalWrite (7, HIGH) ; switch on the fan digitalWrite (5, HIGH) ; switch on the Blue digitalWrite (3, LOW) ; switch off the red digitalWrite (4, LOW) ; switch off the green } else { Serial.println(Optimum Humidity) ; } if (ti = T && hi = H ) { digitalWrite (7, LOW); switch off the fan digitalWrite (5, HIGH) ; switch on the Blue digitalWrite (4, HIGH) ; switch on the Green digitalWrite (3, HIGH) ; switch on the Red } }