pls verify the code.

Hi all.

I have created a program with arduino uno for controlling humidity in my mushroom grow room.
There are two rooms and i am trying to control humidity of each room with one pressure pump , two solenoid valves and relays. I am trying to keep the humidity range in each room in between 75 - 88.
As per my planning if the humidity in one room is below 75 the relays connected to pressure pump and solenoid valve for that particular room to be turned on and would be turned off on exceeding 88,and the same procedure for the other room.I have created code for this and as i am beginner i think it is better to present the code to the experienced guys before testing ,pls check my codes and help to rectify any problems.

#include <dht.h>

dht DHT;

#define DHT1_PIN 2
#define DHT2_PIN 4
#define DHT1TYPE DHT11
#define DHT2TYPE DHT11
int pinout1 =7;
int pinout2 =8;
int pinout3 =12;

void setup(){
  pinMode(pinout1, OUTPUT);
  pinMode(pinout2, OUTPUT);
  pinMode(pinout3, OUTPUT);
}
void loop()
{
  int chk =DHT.read11(DHT1_PIN);
  if (DHT.humidity <75) {
    if (digitalRead(pinout1 == HIGH)){
      digitalWrite(pinout2, HIGH);
    }else{
      digitalWrite(pinout1, HIGH);
      digitalWrite(pinout2, HIGH);
    }
  }
  if (DHT.humidity >88) {
  digitalWrite(pinout1, LOW);
      digitalWrite(pinout2, LOW);
    }
    delay(5000);
    
    int chk2 =DHT.read11(DHT2_PIN);
  if (DHT.humidity <75) {
    if (digitalRead(pinout1 == HIGH)){
      digitalWrite(pinout3, HIGH);
    }else{
      digitalWrite(pinout1, HIGH);
      digitalWrite(pinout3, HIGH);
    }
  }
  if (DHT.humidity >88) {
  digitalWrite(pinout1, LOW);
      digitalWrite(pinout3, LOW);
    }
    delay(5000);
}

abhisheksuma:
as i am beginner i think it is better to present the code to the experienced guys before testing

You have that the wrong way round. Test first.

If there is no problem you won't need help. If there is a problem you need to tell us what it is.

...R

ok .....thanks

The code is probably wrong.
First off, it is not a good idea to have variables named pinout1, pinout2 and pinout3. We can’t read it and you won’t be able to a month from now. You should Name variables, for example, relayPin.

If humidity is < 75, you seem to be turning the water on. Then you immediately test to see if the humidity, which you have not re-read, might have magically jumped to over 88. It never will.

It is better to define and use values like pumpOn and pumpOff instead of using coding like:
digitalWrite(pinout1, HIGH);

How much more readable would this line be:
digitalWrite(pinPump, pumpON);

JaBa:
How much more readable would this line be:
digitalWrite(pinPump, pumpON);

almost as readable as:

pumpOn();

functions rock!

abhisheksuma:

    if (digitalRead(pinout1 == HIGH)){

Take a close look at that line and all your other lines and compare them to the reference page:
https://www.arduino.cc/en/Reference/DigitalRead

BulldogLowell:

pumpOn();

functions rock!

A function for a single line of easy to understand code? They do rock but that’s going too far.

pert:
Take a close look at that line and all your other lines and compare them to the reference page:
digitalRead() - Arduino Reference
A function for a single line of easy to understand code? They do rock but that's going too far.

well, you may also want to record the state and other things...
:confused: