if statement problem

I am working on a project where if the temp sensor becomes open (pin 8 goes LOW) then pin 13 also goes low and stays low. If the pressure sensor( pin 9 goes low) I want pin 13 to also go low and stay low. So if there if there is too much pressure it shuts it off and it stays off or if it gets to hot it shuts it off and it stays off. I think everything with the code is good except the last (if) statement because whatever I have first after the if statement either TempSwitch or PressureSwitch works fine. For instance how I have the code posted the TempSwitch will work fine but the PressureSwitch will not turn the auger (pin 13) off.

Thank You very much for your help

boolean PressureSwitch = false;
boolean TempSwitch = false;
void setup() 
{                
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(13, OUTPUT); // auger motor 
pinMode(8,INPUT); //from pressure switch
pinMode(2,OUTPUT); // to led status for pressure switch
pinMode(9,INPUT); // input from temp switch
pinMode(3,OUTPUT); // output to temp switch led status
}

void loop() 
{
  if(digitalRead(8)== LOW)
{
  PressureSwitch = true;
  digitalWrite (2,HIGH); // lights led pressure status alarm
}
if(digitalRead(9)==LOW)
{
TempSwitch = true;
digitalWrite (3,HIGH);
}

    if(!TempSwitch||!PressureSwitch)
{

  digitalWrite(13, HIGH);   // set the Auger Motor on
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // set the Auger Motor off
  delay(1000);              // wait for a second
}

}
  PressureSwitch = true;

The name PressureSwitch does not give any clue as to why you are assigning it a value of true.

A name like overPressure (or overTemperature) would.

    if(!TempSwitch||!PressureSwitch)

I think you want AND there (&&) not OR.

Thank you very much. I changed the names you were right it makes alot more since how you said.

Thank you,

Without knowing more about your setup, this may be irrelevant, but I would want the auger to start up again if possible after an over temp/pressure situation had ended. I know you mentioned in the other thread that by the time these are resolved, the fire is out, so you're just filling the stove with unlit pellets. Is there anything you can do with the DS18B20 to measure the temperature in the smoke stack, to get a more rapid response to falling temps? I assume its temp range is a problem, but you can adjust for that by measuring further from the stove.

PaulS:     if(!TempSwitch||!PressureSwitch)

I think you want AND there (&&) not OR.

I think Gledhill did that right, he needs OR, as he said in his statement:

Gledhill: So if there is too much pressure it shuts it off and it stays off or if it gets to hot it shuts it off and it stays off.

@Gledhill.. As you said u need to shut it off then stays off, so why you are making it first HIGH then LOW?? And whats delay doing there?? just write:

digitalWrite(13,LOW);

I think you just copy and pasted the code of example "Blink".

wildbill: but I would want the auger to start up again if possible after an over temp/pressure situation had ended.

So wildbill is right, you must not make it LOW, and keep it LOW, you should have some mechanism to make it going normally again while the conditions goes back to normal.

I think Gledhill did that right, he needs OR, as he said in his statement:

No, because of the !s in the test. The test says (now) if the temperature is not over the limit OR the pressure is not over the limit, turn the auger on.

Really, it should say if the temperature is not over the limit AND the pressure is not over the limit, turn the auger on.

http://en.wikipedia.org/wiki/De_Morgan%27s_laws Always a worthwhile read.

"The negation of a conjunction is the disjunction of the negations." and "The negation of a disjunction is the conjunction of the negations."

Oh, yeah. Clear as mud.

When we look at the language, I think you have to allow for the fact that when Augustus formulated his laws, the AND, OR, NOT gate family were about a century in the future.

oh yes PaulS :wink:

PaulS:
“The negation of a conjunction is the disjunction of the negations.” and
“The negation of a disjunction is the conjunction of the negations.”

Got it… Thanks for correcting…