Assistance with code DHT11 actioning relays

Greetings,
I have been working on this little project and i need to have the readings from the DHT11 sensor switch relays on or off. I am still very new to coding and have been struggling to make sense of aspects of it. This code all compiles fine and the DHT 11 sensor is outputting values but none of my relays are cycling. assistance and guidance would be appreciated.

 #include <dht11.h>
#define DHT11PIN 2 //temp sensor
#define Relay1_pin 4 //pin for heat loop
#define Relay2_pin 6 //pin for cool loop
#define Fan_pin 7 //pin for fan

dht11 DHT11;

void setup()
{
  Serial.begin(9600);
  pinMode(PIN4, OUTPUT);
  pinMode(PIN7, OUTPUT);
  pinMode(PIN6, OUTPUT);
}

void loop()
{
  Serial.println();

    int chk = DHT11.read(DHT11PIN);
      Serial.print((float)DHT11.temperature,2);//prints temp in serial 
      Serial.print(",");//prints comma in serial 
      Serial.print((float)DHT11.humidity,2);//prints humidity in serial  
      //Serial.println();//carriage return

    if (DHT11.temperature <33)
    {
    digitalWrite (PIN4,HIGH); //heat on
    digitalWrite (PIN7,HIGH); //fan on
  }else{
    digitalWrite (PIN4,LOW); //heat off
    digitalWrite (PIN7,LOW); //fan off
  }

      if (DHT11.temperature >36)
    {
    digitalWrite (PIN6,HIGH); //cool on
    digitalWrite (PIN7,HIGH); //fan on
  }else{
    digitalWrite (PIN6,LOW); //cool off
    digitalWrite (PIN7,LOW); //fan off
  }

  delay(5000);

}`Preformatted text`

Tell us how these correspond to each other ?

#define Relay1_pin   4 //pin for heat loop
#define Relay2_pin   6 //pin for cool loop
#define Fan_pin      7 //pin for fan

Versus


  pinMode(PIN4, OUTPUT);
  pinMode(PIN7, OUTPUT);
  pinMode(PIN6, OUTPUT);

It compiles :thinking:

Thanks for the reply.
In the sense that when i click verify/compile it gives no errors. It is kind of a hodgepodge of various walkthroughs i have found. It is super challenging to try and learn all of this with no face to face in classes. At least to me it is.

Those two code segments do not agree with each other.

Hi Thelaw,

welcome to the Arduino-forum.
Well done to post your code as a code-section in your very first posting.

I can't offer face to face teaching but reading a tutorial.
As you mentioned face-to-face communication / learning give this tutorial a try.

I'm very interested to hear espescially from you as you are a newcomer if you find this particular tutorial hard to understand or medium or easy to understand. I'm not the author of this tutorial but to me it seems easy to understand.

I would like to have this confirmed by real newcomers.

Arduino Programming Course

So give it a try and report your opinion about this tutorial.

Be the change you want to see in the world
best regards Stefan

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.