#include <dht.h>

#define led1 2
#define led2 3

dht DHT;
#define DHT22_PIN 4
#define DHT22_PIN5 5
#define DHT22_PIN6 6
#define DHT22_PIN7 7

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);  // Serial.begin(9600);
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(DHT22_PIN, INPUT);
  pinMode(DHT22_PIN5, INPUT);
  pinMode(DHT22_PIN6, INPUT);
  pinMode(DHT22_PIN7, INPUT);
}

void loop() {
  uint32_t start = micros();
  int chk = DHT.read22(DHT22_PIN);
  int chk = DHT5.read22(DHT22_PIN5);
  int chk = DHT6.read22(DHT22_PIN6);
  int chk = DHT7.read22(DHT22_PIN7);
  uint32_t stop = micros();

  float t = (DHT.temperature), t5 = (DHT5.temperature), t6 = (DHT6.temperature), t7 = (DHT7.temperature), ;
  float h = (DHT.humidity);

  // put your main code here, to run repeatedly:
  if(t<30 and t5<30 and t6<30 and t7<30){
    //solenoid valve open
    digitalWrite(led2, HIGH);
    digitalWrite(led1, LOW);
  }else if(t >=30 && t<50){
    digitalWrite(led2, HIGH);
    digitalWrite(led1, HIGH);
  }else{
    digitalWrite(led2, LOW);
    digitalWrite(led1, HIGH);
  }
  
  Serial.print("Temperature, \t");
  Serial.println(t);
  // Serial.print("Kelembaban, \t ");
  // Serial.print(DHT.humidity, 1);
  
   
   
  // Serial.println("led1 nyala");
  // delay(2000);
  // digitalWrite(led1, LOW);
  // digitalWrite(led2, HIGH);
  // Serial.println("led2 nyala");
  // // delay(2000);
}