NPN Sensor odd results

Hi all,

So I have a NPN Proximity sensor sending input to an arduino. Everything is working great except when the sensor is sending input to the arduino, then I set the arduino to a "inactive" mode, then reset it back to "active" mode. After this is done, the input from the sensor stays as HIGH even if the sensor isn't activated.

The sensor works fine till its interrupted by the arduino so I don't believe its a pull down resistor issue but I could be wrong I suppose.

      railCheck = digitalRead(sensorArray[4]);
      if ((railCheck == HIGH) && (railCheckNext == 0)) {
        Serial.println("Rail Check Activated");
        previousTimer2 = currentTime;
        digitalWrite(panelLed5, HIGH);
        digitalWrite(solenoidArray[6], HIGH);
        railCheckNext = 1;
      }
      if (railCheckNext == 1) {
        railCheck = digitalRead(sensorArray[4]);
        if (railCheck == LOW) {
          previousTimer2 = currentTime;
          railCheckNext = 2;
        }
      }
      if (railCheckNext == 2) {
        railCheck = digitalRead(sensorArray[4]);
        if (railCheck == HIGH) {
          railCheckNext = 1;
        }
        if ((railCheck == LOW) && (currentTime - previousTimer2 >= sysArray[5])) {
          digitalWrite(solenoidArray[6], LOW);
          digitalWrite(panelLed5, LOW);
          previousTimer2 = currentTime;
          Serial.println("Rail Check Finished");
          railCheckNext = 0;
        }
      }

Sensor Information:
Model#: lj18a3-8-z/bx

So again, the above code works fine, till the arduino stops reading the sensors input while its "LOW", then the output from the sensor stays HIGH. So its reading 5V instead of 0V. I've used my meter to check this and the output from the sensor is sending 5V when it should be 0V. Ideas? confused?

Assuming the sensor has an open collector output that pulls low on activation do you have a pullup resistor on the input pin or is the pinMode set "INPUT_PULLUP"? Can you post a circuit drawing?
Also what is "inactive mode"?

edgemoron:
Assuming the sensor has an open collector output that pulls low on activation do you have a pullup resistor on the input pin or is the pinMode set "INPUT_PULLUP"? Can you post a circuit drawing?
Also what is "inactive mode"?

The pinmode is set to INPUT_PULLUP.

A circuit of the sensor is here:
MDL#: LJ18A3-8-Z/BX

My circuit is here:

Its google so it has to be clicked, not embedded.

I'll try to explain inactive mode without posting my entire code because it is a very large piece and would be like fishing for a needle in a haystack. Inactive mode is like if a sensor A doesn't see an object then it doesn't run a digitalRead of SensorB inside the main loop.

Example:

if(SensorA == HIGH){
  active = 1;
}
if(active == 1){
  digitalRead(SensorB);
}

This is a very crude example and I can post my entire code but its a fairly huge program so it may not be helpful..

For now I'll just put it in lay mans terms, The system works great on power up. If a malfunction is detected (Not with the arduino, with the machine the arduino controls), It shuts down a motor and all relays. I have a reset button that once hit, it turns the relays back to normal state, and / or starts reading all the sensors again.

....... (5 mins later)

I just got it figured out. I never reset one of my variables. Got it working!