Model Railroad Crossing Lights

Share on facebook
Share on google
Share on twitter
Share on linkedin
A VPN is an essential component of IT security, whether you’re just starting a business or are already up and running. Most business interactions and transactions happen online and VPN

For the Charleston Area Model Railroad Club, We have combined our train detector circuit from the scale speedometer project with a LED Crossing Light to make it simple to indicate a train is coming to a crossing. The next step is to add a servo operated crossing bar, and bell sounds, but I’m getting ahead of myself.

Get the IR sensor board at

The Circuit:
The detection circuit is the same as the scale speedometer. A TCRT5000 IR LED / Phototransistor pair, with two resistors, connected to an Arduino input (D8). You can lower the value of the Phototransistor pullup resistor to 10k-50k ohm (instead of 80k-100k ohm) to reduce it’s sensitivity to ambient light. Increase the value of the IR LED resistor (68 Ohm) to reduce range. Never drop IR resistor below 68 Ohms.

The output is a off the shelf LED crossbuck with 2 red LED’s and a common anode. I put a 300 ohm resistor on the common and connected to 5v, and connected the two cathodes directly to arduino outputs D11 and D12. Add a second LED Crossbuck (with resistor) to the same outputs for the other side of the crossing. See the video below the code.

The code checks to see if the phototransistor is lit (a 0 or LOW), and activates the lights (LOW is lit, HIGH is off)) as long as it is.

//int sensor1 = 1;

void setup() {
  pinMode(8, INPUT);
  pinMode(12, OUTPUT);
  pinMode(11, OUTPUT);

// the loop function runs over and over again forever
void loop() {
  digitalWrite(11, HIGH);
  digitalWrite(12, HIGH);

  int sensor1 = digitalRead(8);
  if (sensor1 == LOW){
    digitalWrite(12, HIGH);
    digitalWrite(11, LOW);
    digitalWrite(12, LOW);
    digitalWrite(11, HIGH);

Finished board for two track sensors and 2 crossing lights.

Steve Spence

Steve Spence

Leave a Reply

9 thoughts on “Model Railroad Crossing Lights”

  1. I misspoke in the video, the LED's have a common anode, connected to +5vdc through a 300 Ohm resistor, and the two cathodes are connected to Arduino pins 11 & 12, respectively.

  2. Have you added block detection code? I currently use 2 sensors one and the entrance and exit of the block. I am having issues though running 2 trains and keeping each block separate. are you able to assist? Thanks

  3. In this case would not it be better to combine the two (electronic circuits and arduino)?
    Let the arduino do what he does best. Check the sensors, turn the lights and sound on and off and start the servo.

Leave a Comment

Your email address will not be published. Required fields are marked *