The code and instructions for making a level crossing for 1 to 3 tracks. It has four gates and flashing lights with provisions to add lights on the gates and warning bells.
Makes A full Featured level crossing that you can modify to suit your needs.
Grade Crossing And Other Layout Animation Video Tutorials
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 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.
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.
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.
Materials Needed To Make A Level Crossing With Automated Lights
There are two basic parts to a level crossing with automated lights. Those are the lights themselves and the control circuitry.
This page focuses on the control circuitry The lights are covered in detail in this page (How To Make Level Crossing Flashing Lights) and a video showing how to make them is in the gallery above.
The control circuitry is made up of two things. The operating program (code) and the circuit board.
Note that the code we provide can be used to control lights on a crossing with 1 to 3 tracks. It also has provisions to add gates. If you want lights only, just don’t make connections to gate servos.
We recommend using this sketch rather than one that only controls the lights because you may want to use it later on another crossing that has gates. And it also has provisions for warning bells and adding flashing lights on the gates.. Adding those is shown in one of the videos above and a text guide is at this page.
The code can be downloaded from Pastebin Click here.
The images below show the circuit board.
Note 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.
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.
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
Mechanical Pin Headers
3mm replacement IR Sensitive LEDs
You can get all these parts in a package at this link.
Related Level Crossing Pages
How To Install A Level Crossing In Your Layout. –
How To Add Warning Bells At Model Railroad Level Crossings –
How To Make A Level Crossing Control Circuit Board –
How To Install Automated Level Crossing Operating Mechanism