&& statement not working correctly

In the following code, the && statement is not working correctly for limitFloorPin

else  if (digitalRead (buttonDownPin) == LOW && digitalRead (limitDeployPin) == LOW && digitalRead (limitFloorPin) == LOW) {
    digitalWrite (downPin, HIGH);
    Stage = 3;
  }

Even when limitFloorPin is HIGH the program skips straight to Stage =3. I know that limitFloorPin is behaving correctly through the hardware because if I change the limitFloorPin state in the previous lines of code it will never get to Stage = 3.

if (digitalRead (buttonDownPin) == LOW && digitalRead (limitDeployPin) == HIGH && digitalRead (limitFloorPin) == HIGH) {
    digitalWrite (deployPin, LOW);
  }
  else  if (digitalRead (buttonDownPin) == LOW && digitalRead (limitDeployPin) == LOW && digitalRead (limitFloorPin) == HIGH) {
    digitalWrite (deployPin, HIGH);
    digitalWrite (downPin, LOW);
  }
  else  if (digitalRead (buttonDownPin) == LOW && digitalRead (limitDeployPin) == LOW && digitalRead (limitFloorPin) == LOW) {
    digitalWrite (downPin, HIGH);
    Stage = 3;
  }

Also, it behaves correctly on the way up, entire code below.

int buttonDownPin = 14;
int buttonUpPin = 15;
int limitOpenPin = 2;
int limitDeployPin = 3;
int limitFloorPin = 4;
int limitDownPin = 5;
int limitStowPin = 6;
int limitFoldPin = 7;
int OpenPin = 8;
int ClosePin = 9;
int deployPin = 10;
int stowPin = 11;
int downPin = 12;
int upPin = 13;
/*Stage1 //Door closed, ramp stowed, lift up
  Stage2 //Door open, ramp stowed, lift up
  Stage3 //Door open, ramp deployed, lift floor level
  Stage4 //Door open, ramp deployed, lift down*/
int Stage = 1;

void setup() {
  // put your setup code here, to run once:
  pinMode (buttonDownPin, INPUT_PULLUP);
  pinMode (buttonUpPin, INPUT_PULLUP);
  pinMode (limitOpenPin, INPUT_PULLUP);
  pinMode (limitDeployPin, INPUT_PULLUP);
  pinMode (limitFloorPin, INPUT_PULLUP);
  pinMode (limitDownPin, INPUT_PULLUP);
  pinMode (limitStowPin, INPUT_PULLUP);
  pinMode (limitFoldPin, INPUT_PULLUP);
  pinMode (OpenPin, OUTPUT);
  pinMode (ClosePin, OUTPUT);
  pinMode (deployPin, OUTPUT);
  pinMode (stowPin, OUTPUT);
  pinMode (downPin, OUTPUT);
  pinMode (upPin, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:

  if (digitalRead (buttonUpPin) == LOW || digitalRead (buttonDownPin) == LOW) {
    OutIn();
  }

  else {
    for (int i = 8; i <= 13; i++) {
      // all outputs (8-13) off (relay board is active low)
      digitalWrite(i, HIGH);
      delay (10);
    }
  }
}

void OutIn() {
  if (Stage == 1) {
    Door();
  }
  if (Stage == 2) {
    Fold();
  }
  if (Stage == 3) {
    Floor();
  }
  if (Stage == 4) {
    Platform();
  }
}

void Door() {
  if (digitalRead (buttonUpPin) == LOW) {
    digitalWrite(ClosePin, LOW);
  }

  if (digitalRead (buttonDownPin) == LOW && digitalRead (limitOpenPin) == HIGH) {
    digitalWrite (OpenPin, LOW);
  }
  else  if (digitalRead (buttonDownPin) == LOW && digitalRead (limitOpenPin) == LOW) {
    digitalWrite (OpenPin, HIGH);
    Stage = 2;
  }
}


void Fold() {
  if (digitalRead (buttonUpPin) == LOW  && digitalRead (limitStowPin) == HIGH && digitalRead (limitFoldPin) == HIGH) {
    digitalWrite(upPin, LOW);
  }
  else  if (digitalRead (buttonUpPin) == LOW  && digitalRead (limitStowPin) == LOW && digitalRead (limitFoldPin) == HIGH) {
    digitalWrite (upPin, HIGH);
    digitalWrite (stowPin, LOW);
  }
  else   if (digitalRead (buttonUpPin) == LOW  && digitalRead (limitStowPin) == LOW && digitalRead (limitFoldPin) == LOW) {
    digitalWrite (stowPin, HIGH);
    Stage = 1;
  }



  if (digitalRead (buttonDownPin) == LOW && digitalRead (limitDeployPin) == HIGH && digitalRead (limitFloorPin) == HIGH) {
    digitalWrite (deployPin, LOW);
  }
  else  if (digitalRead (buttonDownPin) == LOW && digitalRead (limitDeployPin) == LOW && digitalRead (limitFloorPin) == HIGH) {
    digitalWrite (deployPin, HIGH);
    digitalWrite (downPin, LOW);
  }
  else  if (digitalRead (buttonDownPin) == LOW && digitalRead (limitDeployPin) == LOW && digitalRead (limitFloorPin) == LOW) {
    digitalWrite (downPin, HIGH);
    Stage = 3;
  }



  //if upButton fold platform until fold limit, set to stage1
  //if downButton lower platform until floor limit, set to stage3
}
void Floor() {
  if (digitalRead (buttonUpPin) == LOW) {
    delay (1000);
    Stage = 2;
  }
  else if (digitalRead (buttonDownPin) == LOW) {
    delay (1000);
    Stage = 4;
  }
  //if upButton stop motion while button pressed, set to stage2
  // if downButton stop motion while button pressed, set to stage4
}
void   Platform() {
  if (digitalRead (buttonUpPin) == LOW && digitalRead (limitFloorPin) == LOW) {
    digitalWrite(upPin, LOW);
  }
  else  if (digitalRead (buttonUpPin) == LOW && digitalRead (limitFloorPin) == HIGH) {
    digitalWrite (upPin, HIGH);
    Stage = 3;
  }

  else if (digitalRead (buttonDownPin) == LOW) {// && (limitDownPin) == HIGH) {
    digitalWrite (downPin, LOW);
  }
//  else if (digitalRead (buttonDownPin) == LOW && (limitDownPin) == LOW) {
//    digitalWrite (downPin, HIGH);
//  }

  // if upButton raise lift to floor, set to Stage3
  // if downButton lower lift until down limit* /
}

I know there's another way to write this code using switch/case. I will work on getting a great example that was sent to me working, but for now I'd like to understand what I have, any thoughts?

Video of the project can be seen here - Crow River wheelchair lift using Arduino microcontroller - YouTube

Whenever I have problems like this I print the values being tested so that I can see the values and also establish that the code I want is being executed.

I'd also put in some more ( ) to make sure the comparisons are being done as intended:

else  if ( (digitalRead (buttonDownPin) == LOW) && (digitalRead (limitDeployPin) == LOW) && (digitalRead (limitFloorPin) == LOW) ) {
    digitalWrite (downPin, HIGH);
    Stage = 3;
  }
&& (limitDownPin) == HIGH

what's limitDownPin? It's the number 5 . HIGH is just #defined as 1. 5==1 will always be false.

did you mean to read the value of pin 5 with digitalRead()?

Thanks everyone. I thought the bracket answer was going to fix this for sure, it did not. It must be a hardware problem, so I'll use the print function to help find it.

what's limitDownPin? It's the number 5 . HIGH is just #defined as 1. 5==1 will always be false.

did you mean to read the value of pin 5 with digitalRead()?

Good catch! I commented out that part of the code anyway since the switch got mangled over the years, now I see it wouldn't have worked anyway. Hopefully one day I'll be able to "see" the problems in the code before I actually hook everything up and find things not working.

There is only one way to "see" a problem in the code. That is to go through the code line by line - ignoring the comments! - and execute it just like the computer would. Use a pencil and paper to write down intermediate values as necessary.