Newbie Problems I guess!!, Help please

This section of my code does this make sense and do you think it will work.

I'm using UNO and DHT11

Thanks!!!

if (f>70) // if temperature is above 70 turn cooling unit on
  {
  digitalWrite(PUMP,ON);
  digitalWrite(INTFANS,ON);
  digitalWrite(OUTFANS,ON);
}
else if (digitalRead(PUMP)==ON && digitalRead(INTFANS)==ON && digitalRead(OUTFANS)==ON)
(f<=68); //if cooling unit is on turn it off when I reach 68 
{
  digitalWrite(PUMP,OFF);
  digitalWrite(INTFANS,OFF);
  digitalWrite(OUTFANS,OFF);
}
if (f<66) // if temperature is below 66 turn heating unit on
{
  digitalWrite(HEATER,ON);
  digitalWrite(PUMP,ON);
  digitalWrite(INTFANS,ON);
}
else if (digitalRead(HEATER)==ON && digitalRead(PUMP)==ON && digitalRead(INTFANS)==ON)
(f>=68); // if heating unit is on turn it off when I reach 68 
{
  digitalWrite(HEATER,OFF);
  digitalWrite(PUMP,OFF);
  digitalWrite(INTFANS,OFF);
}

Your else if is very weird read it again (the part about the temperature). what needs to be in the condition and what needs to be executed ?

Should look like this

if (condition1) { statements1;}
else if (condition2) {statements2;}
else if (condition3) {statements3;}
...
else {statementsOther}

Instead of reading again all the pins status you could set a boolean when the system is on and only check that boolean (and reset it when you turn it off)

so this is better?

if (f>70) // if temperature is above 70 turn cooling unit on
  {
  digitalWrite(PUMP,ON);
  digitalWrite(INTFANS,ON);
  digitalWrite(OUTFANS,ON);
}
else if (digitalRead(PUMP)==ON && digitalRead(INTFANS)==ON && digitalRead(OUTFANS)==ON)
(f<=68); //if cooling unit is on turn it off when I reach 68 
{
  digitalWrite(PUMP,OFF);
  digitalWrite(INTFANS,OFF);
  digitalWrite(OUTFANS,OFF);
}
else if (f<66) // if temperature is below 66 turn heating unit on
{
  digitalWrite(HEATER,ON);
  digitalWrite(PUMP,ON);
  digitalWrite(INTFANS,ON);
}
else if (digitalRead(HEATER)==ON && digitalRead(PUMP)==ON && digitalRead(INTFANS)==ON)
(f>=68); // if heating unit is on turn it off when I reach 68 
{
  digitalWrite(HEATER,OFF);
  digitalWrite(PUMP,OFF);
  digitalWrite(INTFANS,OFF);
}

No

else if (digitalRead(PUMP)==ON && digitalRead(INTFANS)==ON && digitalRead(OUTFANS)==ON)[color=red]
(f<=68);[/color]

so if my cooling components come on after 70 deg.. how do i get them to shut off at 68 deg?

I know (f<=68) ...is my condition ... but i only wan that to happen when they have been turned on

What are all those && thingy you do? What does this operator do? And how should you write the condition to express in code what you are saying in plain English as

If inside fan is on AND outside fan is on AND pump is on AND temperature is less than 68 then...

I believe those && " are and also " that's what i was told....is that correct?

this is what I would like to do

everything is off
my temperature rises above 70 so..
my cooler (insidefan, outsidefan and pump) all turn on

I would like to turn them off when it cools down to 68 so i have a 2 degree dead zone (not going on and off as often)

then when temperature goes down to below 66
my heater (insidefan, pump and heater) all turn on
I would like them to turn off when it warms up to 68

Yes they are

So how do you code the if described above in post #5? Compare to what you wrote where is that last AND?

does the fact that i'm using the inside fans for both heating and cooling state confuse the arduino?

what's your recommendation?

My recommendation is fix the @#!!&^ Line of code that is wrongly written....

Read again answer #3 look at the red part. Is it in the condition or is that the statement?

How's this??

if (f>70) // if temperature is above 70 turn cooling unit on
  {
  digitalWrite(PUMP,ON);
  digitalWrite(INTFANS,ON);
  digitalWrite(OUTFANS,ON);
}
else if
(f<=68 && digitalRead(PUMP)==ON && digitalRead(INTFANS)==ON && digitalRead(OUTFANS)==ON)
//if cooling unit is on turn it off when I reach 68 
{
  digitalWrite(PUMP,OFF);
  digitalWrite(INTFANS,OFF);
  digitalWrite(OUTFANS,OFF);
}
if (f<66) // if temperature is below 66 turn heating unit on
{
  digitalWrite(HEATER,ON);
  digitalWrite(PUMP,ON);
  digitalWrite(INTFANS,ON);
}
else if 
(f>=68 && digitalRead(HEATER)==ON && digitalRead(PUMP)==ON && digitalRead(INTFANS)==ON) 
// if heating unit is on turn it off when I reach 68 
{
  digitalWrite(HEATER,OFF);
  digitalWrite(PUMP,OFF);
  digitalWrite(INTFANS,OFF);
}

The conditions are now written correctly - could argue there is no point checking the fans status given that if the heater or cooler is on, they are on too, right?

J-M-L
Thanks for your help and patience!!!!
Got it now! Everything is working perfect!!

Why didn't you just say so....LOL!!!!!!

Thanks again!!!!

what would have you learnt if I gave you the solution

Now you are smarter AND you have a working program. how does it feel? :slight_smile:

Great!!!!!! Thanks again!!