Inserting IR sensor code into existing project

Yes you guessed it. I am trying to animate this signal in the photo. The IR sensors will be mounted directly under the signal cantilever. one sensor on each track.


g

You are correct I The buttons need to be ignored when the IR sensor is occupied.

const int buttonPin         = A1;
const int IRSensor          = A2;

const int ledPinredTop      = 13;
const int ledPinyellowTop   = 12;
const int ledPingreenTop    = 11;
const int ledPinredBtm      = 10;
const int ledPingreenBtm    = 9;

#else
const int buttonPin         = 7;

const int ledPinredTop      = 4;
const int ledPinyellowTop   = 3;
const int ledPingreenTop    = 2;
const int ledPingreenBtm    = 5;
const int ledPinredBtm      = 6;
const int IRSensor          = 8;

I am confused why are the LEDs and IR sensors being declared twice on different Pins?

Thanks!