How To Make Automated Level Crossing With Flashing Lights Plus 4 Gates For 1 To 4 Tracks

The code and instructions for making a level crossing for one or more tracks.  It has four gates and flashing lights.

The code is complete.  You do not have to either know nor do any coding. You may, of course, make changes  but it is presented ready to run.  You can see it in operation below.

Grade Crossing And Other Layout Animation Video Tutorials

This series of videos gives you a start with layout animation.  To stay up to date and be notified as we add to this series, subscribe and click on the bell in one of the videos below.

 

 

The controlling sketch can be changed to increase or decrease the number of tracks. You may also add flashing lights to the gates.

The action is intimated by IR sensors located on the East and West sides of the crossing. The sensors are under track, between ties, with the usual 5mm detector attached LEDss changed to remote 3mm detectors.

This crossing is part of our USING ARDUINO FOR FUN SKETCHBOOK that contains this and many other ready to run Arduino projects.

In that sketchbook there are other level crossing projects that may interest you:

Arduino Multi-Track Level Crossing With Four Gates Flashing Lights And Alarm Bells  –

Model Railroad Level Crossing With Flashing Lights And Warning Bells But No Gates

How To Install An IR Sensor Under Track – Shows you how to install the sensors without a lot of work under the layout and, at the same time, in a way that they are not easily notice.

Features

The gates on the road crossing entrance and road crossing exit close at different times.  This mimics the prototypes that allow vehicles that are on the tracks to properly exit when the entrance gates start to close.

Multiple trains can be in the crossing at the same time.  The gates will not open until the last train leave the protected area.

After the sensors signal that the last train has left the protected area, there is a 20 second delay (adjustable) to ensure that the signal detected all cars in the consist.

You can use this for one or more tracks.  The upper limit it the number of pins on your Arduino board.  The board used in this project is an Arduino Nano.

For a single road lane crossing, just eliminate the road exit gate.

Code

For you convenience, the code is available on Pastebin at this link.  Click here.

Live Code Simulation

This link takes you to the WOKWI  code simulator where you can test the sketch. Click Here.

Mock-up Demonstration

Model Railroad Level CrossingThe video under the image shows how the gates work.

 

 

 

 

Circuit Board

The images below show the circuit board.

level crossing circuit boardNote that there are 4 resistors that are not connected.  If you wish to have flashing lights on your gates, it is just a matter of adding wires to the appropriate pins.  The pins are shown in the program.

 

 

 

 

 

level crossing circuit board wiring

There is a gap shown in the image.  That ensures that the entrance and exit gates can be controlled separately.

I used perf board.  You might find it easier to use vero board and arrange the pin headers to take advantage of the continuous strips.

 

 

Materials Used

Servos x 4

Resistors x 2  If you are going to add flashing lights to the gates you will need a total of 6

Arduino Board – A Nano is fine.

IR Sensors – 2 for each track

Female Dupont Pin Headers

Pin Connectors

Mechanical Pin Headers

3mm replacement IR Sensitive LEDs

Prototype Board

You can get all these parts in a package at this link.

 

Related Level Crossing Pages

How To Make Level Crossing Gates

How To Make Level Crossing Flashing Lights

Automated Level Crossing Lights

Automated Level Crossing With Flashing Lights Plus 2 Gates For 1 To 4 Tracks

Automated Level Crossing With Flashing Lights Plus 4 Gates For 1 To 4 Tracks

Bells For Level Crossing Flashing Lights


We hope that you found the information in this page useful. The internet is all about getting and giving. And giving back is the best. Please donate $1 or more to aid us in our continuing quest to add to and polish the information in our site.


Scroll to top