Train Crossing

Hi,
Im currently working on a project that will have multiple of these codes running at once, using a multitask library to do so. However im having an issue nutting out these sensors (Light dependent resistors, LDR).
The idea is:
Train Passes over LDR(0), connected to A0
Turn LED on. (ill need it to run on a blinking code but ill work that out later for now)
When train passes over LDR(1), Connected to A1, positioned after the crossing.
Turn LED off.

Simple as that.

Issue im having is for some reason LDR(1) at A1 is constantly giving me a reading of 0, thus the light turns off imidiently, even in direct light.
Heres the code below.

const int led=2; // variable which stores pin number

void setup() 
{
  pinMode(led, OUTPUT);  //configures pin 2 as OUTPUT
}

void loop() 
{
   int sensor_value = analogRead(A0);
  if (sensor_value < 150)// the point at which the state of LEDs change 
    { 
      digitalWrite(led, HIGH);  //sets LEDs ON
    }
 
 
 int sensor_value2 = analogRead(A1);
 
 if (sensor_value2 < 150);
    {
        digitalWrite(led,LOW); //sets LEDs OFF
    }

}

You need an OR condition so the led is on if EITHER LDR is blocked.

if(sensor_value  < 150 || sensor_value2 <150)
  digitalWrite(led, HIGH);
else
  digitalWrite(led, LOW);

How are the LDRs and pullup/pulldown resistors connected? Can you post a diagram?

That's the diagram, The idea is, the First LDR on the left turns the LED on (it will blink while on)
once the train has passed the crossing and reached the LDR on the right, then and only then will the LED turn off.

What kind of ADC numbers do you get when the LDRs are clear and then with a car parked over them? Also you have to think about light shining through the gaps between cars as they are passing over, might need a short timer or aim the LDRs diagonally.

The LDR's read 200 in light, and around 50 with my finger over. That's not the issue though. the "LED OFF" sensor is always reading zero thus flicking the light off every time.

int LDR0 = A0; // select the input pin for ldr
int LDR1 = A1; // select the input pin for ldr
int SV0 = 0; // variable to store the value coming from the sensor
int SV1 = 0; // variable to store the value coming from the sensor
 void setup() {
 Serial.begin(9600); //sets serial port for communication
 pinMode(13,OUTPUT);
 }
 void loop() {
  SV0 = analogRead(LDR0); // read the value from the sensor
 Serial.println(SV0); //prints the values coming from the sensor on the screen
 if (SV0 < 100)
 {digitalWrite(13,HIGH);
 delay(100);}

 SV1 = analogRead(LDR1); // read the value from the sensor
 Serial.println(SV1); //prints the values coming from the sensor on the screen
 if (SV1 < 100)
 {digitalWrite(13,LOW);
 delay(100);}
 }

the LED now stays on once triggered and off once triggered, now to implement the blinking LED