New to Arduino, Having Trouble With Multiple inputs

Hi, I am trying to use three different obstacle sensors with my Arduino Uno. For some reason only one will work at a time. Is there a reason for this? If not, posting a simple program using multiple sensors which I can learn from would be super helpful.

The sensors I am using are "IR Transmitting and Receiving Tube Photoelectric Switch"

Thanks!

int airHose = 11; // STAGE ONE VALVE (SINGLE)
int entrySensor = 2; // This is our input pin
int entrySensor1 = HIGH; // HIGH MEANS NO OBSTACLE

int primaryForkValve = 13; // STAGE TWO VALVE PART ONE
int pistonSensor = 3;
int pistonSensor1 = HIGH; // HIGH MEANS NO OBSTACLE

int topValve = 12; // STAGE TWO VALVE PART TWO
int isObstaclePin3 = 4;
int isObstacle3 = HIGH; // HIGH MEANS NO OBSTACLE

int x = 0;

void setup() {
pinMode(airHose, OUTPUT);
pinMode(entrySensor, INPUT);

pinMode(primaryForkValve, OUTPUT);
pinMode(pistonSensor, INPUT);

pinMode(topValve, OUTPUT);
pinMode(isObstaclePin3, INPUT);

Serial.begin(9600);
}
void loop() {
entrySensor1 = digitalRead(entrySensor);
pistonSensor1 = digitalRead(pistonSensor);
isObstacle3 = digitalRead(isObstaclePin3);

if (entrySensor1 == LOW)
{
Serial.println("Stage 1 active");
//Part one
digitalWrite(airHose, LOW);
delay(200);
digitalWrite(airHose, HIGH);
//Part two
digitalWrite(topValve, LOW);
digitalWrite(primaryForkValve, HIGH);
delay(1000);
while (pistonSensor1 == HIGH)
{
if (pistonSensor1 == LOW);
{
Serial.println("if loop start");
digitalWrite(topValve, HIGH);
delay(1000);
digitalWrite(topValve, LOW);
digitalWrite(primaryForkValve, LOW);
delay(1000);
}
Serial.println("if loop over");
break;
}
delay(1000);
}
{
Serial.println("Stage one clear");
digitalWrite(airHose, HIGH);

}
delay(200);

}

What kind of sensors?

Post your code using code tags. Post a schematic if you can.

Thanks for the help. I am using an "IR Transmitting and Receiving Tube Photoelectric Switch."

int airHose = 11; // STAGE ONE VALVE (SINGLE)
int entrySensor = 2;  // This is our input pin
int entrySensor1 = HIGH;  // HIGH MEANS NO OBSTACLE

int primaryForkValve = 13; // STAGE TWO VALVE PART ONE
int pistonSensor = 3;  
int pistonSensor1 = HIGH;  // HIGH MEANS NO OBSTACLE

int topValve = 12; // STAGE TWO VALVE PART TWO
int isObstaclePin3 = 4; 
int isObstacle3 = HIGH;  // HIGH MEANS NO OBSTACLE

int x = 0;

void setup() {
    pinMode(airHose, OUTPUT);
    pinMode(entrySensor, INPUT);


    pinMode(primaryForkValve, OUTPUT);
    pinMode(pistonSensor, INPUT);

    pinMode(topValve, OUTPUT);
    pinMode(isObstaclePin3, INPUT);

    Serial.begin(9600);
}
void loop() {
    entrySensor1 = digitalRead(entrySensor);
    pistonSensor1 = digitalRead(pistonSensor);
    isObstacle3 = digitalRead(isObstaclePin3);

    if (entrySensor1 == LOW)
    {
        Serial.println("Stage 1 active");
                                                  //Part one
        digitalWrite(airHose, LOW);
        delay(200);
        digitalWrite(airHose, HIGH);
                                                  //Part two
        digitalWrite(topValve, LOW);
        digitalWrite(primaryForkValve, HIGH);
        delay(1000);
        while (pistonSensor1 == HIGH)
        {
            if (pistonSensor1 == LOW);
            {
                Serial.println("if loop start");
                digitalWrite(topValve, HIGH);
                delay(1000);
                digitalWrite(topValve, LOW);
                digitalWrite(primaryForkValve, LOW);
                delay(1000);
            }
            Serial.println("if loop over");
            break;
        }
        delay(1000);
    }
    {
        Serial.println("Stage one clear");
        digitalWrite(airHose, HIGH);

    }
    delay(200);


}

If the IR receiver section uses an LM393 op-amp you should know that the op-amp output is open-collector.

This means you need a resistor on the output to pull the pin high when the output transistor is turned off.

You can try changing the pinMode for each sensor pin to:

    pinMode(entrySensor, INPUT_PULLUP);

    pinMode(primaryForkValve, OUTPUT);
    pinMode(pistonSensor, INPUT_PULLUP);

    pinMode(topValve, OUTPUT);
    pinMode(isObstaclePin3, INPUT_PULLUP);

and see if that helps.

That seemed to fix it. Thank you so much!