How would you write the expression to test sensors Departure (A or B) HIGH AND Arrival (A or B) HIGH?
The first else if statement shown below doesn't work. Departure A OR Departure B HIgh AND Arrival A OR Arrival B High. The OR doesn't work. Only when both Departure A AND B are HIGH the serial print. The same applies to the third else if statement both Departure A and B have to be low for the statement to function. What am I coding wrong for the OR?
if ((digitalRead(s1DeparturePinA) == LOW || digitalRead(s1DeparturePinB) == LOW) && (digitalRead(s1ArrivalPinA) == HIGH || digitalRead(s1ArrivalPinB) == HIGH)) { Serial.println(F("Train on siding 1 status DEPARTURE")); delay(1); } else if ((digitalRead(s1DeparturePinA) == HIGH || digitalRead(s1DeparturePinB) == HIGH)&& (digitalRead(s1ArrivalPinA) == HIGH || digitalRead(s1ArrivalPinB) == HIGH)) { Serial.println(F("Train on siding 1 status IN TRANSIT")); delay(1); } else if ((digitalRead(s1DeparturePinA) == HIGH || digitalRead(s1DeparturePinB) == HIGH) && (digitalRead(s1ArrivalPinA) == LOW || digitalRead(s1ArrivalPinB) == LOW)) { Serial.println(F("Train on siding 1 status ARRIVAL")); delay(1); s1ArrivalDetect = LOW; } else if ((digitalRead(s1DeparturePinA) == LOW || digitalRead(s1DeparturePinB) == LOW) && (digitalRead(s1ArrivalPinA) == LOW || digitalRead(s1ArrivalPinB) == LOW) && s1ArrivalDetect == LOW) { Serial.println(F("Train on siding 1 status STOP")); delay(1); trainOneOut = LOW; //train selection flip_flop L=train on siding 2 s1ArrivalDetect = HIGH; digitalWrite(l1_TurnoutL, LOW); //unset departure and arrival turnouts for train1 digitalWrite(s1_Power, LOW); //unset power on for train1 digitalWrite(l1_TurnoutR, HIGH); //set departure and arrival turnouts for train2 digitalWrite(s2_Power, HIGH); //set power on for train2 }