Need help integrating code for DC Motor, dual IR break beam sensors, LCD & LED

Hey guys! I am working on a project right now that basically tracks a toy train’s position. So far i have running code for both break beam sensors to be monitored when the connection is disrupted. I need help interfacing this with my Arduino Mega 2560, an LCD, two LEDS and a DC motor. Their functionality is as follows:

The IR break beam sensors (3mm) will be placed at two separate locations on the train tracks at some distance apart from eachother. Once they are triggered by the train passing, the DC motor connected to our Arduino will rotate 90 degrees and rotate a model sized gate on the shaft.
Also, Two LED’s will light up when the IR sensors are triggered as well.

Simultaneously, a message will be sent to the LCD, displaying that the train is passing (possibly how far away it is if possible).

PLEASEEEE HELP ME! i’m desperate. Any contributions would be accepted.

The code for the two IR break beam sensors is as follows:

#define LEDPIN 13
  // Pin 13: Arduino has an LED connected on pin 13
  // Pin 11: Teensy 2.0 has the LED on pin 11
  // Pin  6: Teensy++ 2.0 has the LED on pin 6
  // Pin 13: Teensy 3.0 has the LED on pin 13
 
#define SENSORPIN_A 4
#define SENSORPIN_B 5
// variables will change:
int sensorState_A = 0, lastState_A = 0;
int sensorState_B = 0, lastState_B = 0;  
// variable for reading the pushbutton status
 
void setup() {
  // initialize the LED pin as an output:
  pinMode(LEDPIN, OUTPUT);      
  // initialize the sensor pin as an input:
  pinMode(SENSORPIN_A, INPUT_PULLUP);  
  pinMode(SENSORPIN_B, INPUT_PULLUP);   
  
  Serial.begin(9600);
}
 
void loop(){
  // read the state of the pushbutton value:
  sensorState_A = digitalRead(SENSORPIN_A);
  sensorState_B = digitalRead(SENSORPIN_B);
  // check if the sensor beam is broken
  // if it is, the sensorState is LOW:
  if (sensorState_A == LOW) {     
    // turn LED on:
    digitalWrite(LEDPIN, HIGH);  
  } 
  else {
    // turn LED off:
    digitalWrite(LEDPIN, LOW); 
  }
  
  if (sensorState_A && !lastState_A) {
    Serial.println("No Train");
  } 
  if (!sensorState_A && lastState_A) {
    Serial.println("Train Passing First Sensor");
  }
  lastState_A = sensorState_A;

  
   if (sensorState_B == LOW) {     
    // turn LED on:
    digitalWrite(LEDPIN, HIGH);  
  } 
  else {
    // turn LED off:
    digitalWrite(LEDPIN, LOW); 
  }
  
  if (sensorState_B && !lastState_B) {
    Serial.println("No Train");
  } 
  if (!sensorState_B && lastState_B) {
    Serial.println("Train Passing Second Sensor");
  }
  lastState_B = sensorState_B;
  delay(10);
}

Thanks in advance!