Model Scenery Tutorials

A Comprenshive Modeler's And Model Railroader's Guide

model scenery center

How To Install And Adjust Level Crossing Circuit

There are two aspects to a level crossing circuit.

The first is the circuit board and the second the program.

We are going to discuss the circuit board loaded with a clever program that allows you to make level crossings that fit your scenery.

2 Warning Lights And Bells

2 Gates,  2 Warning Lights And Bells

2 Gates,  4 Warning Lights And Bells

Construction  of the circuit board is covered here.  How To Make A Level Crossing Circuit Board.

Adjusting the Level Crossing Circuit To Fit Your Needs

What The Crossing Circuit Does

The Arduino sketch that controls the lights gates and bells is capable of controlling 2 crossing entrance gates, 2 crossing exit gates and 4 lights on crossings that have 1, 2, or 3 tracks.

The program sits on an Arduino Nano.  You just hook up as few or as many lights and gates as you wish.

Trains approaching the crossing from the East or West, trigger an IR Sensor mounted below the track. Upon triggering, the crossing goes into action.  If more than one train is in the crossing, the crossing stays active until the last train leaves the crossing,  This video shows that in detail. BBBBBBBBBBBBBB

What You Can Do To The Program

At the top of the program there are the following lines of code.

Change these first three lines as you wish.

#define GATE_SPEED 30            // [ms] lower number is higher servo speed
#define BLINK_SPEED 400          // [ms] smaller number is faster blinking
#define GATE_DELAY 4000          // [ms] time between start blinking and gate closing
This next line makes sure a train is really out of the crossing. It is the delay in milli-seconds that the program waits after the IR sensor is not triggered.  It is just a little addition so you don’t start opening gates because the sensor cycles because of a gap between wagons.
#define END_OF_TRAIN_DELAY 2000  // [ms] time to wait before deciding this was the end of the train
#define GATE_OPEN_ANGLE_1 90     //change as you wish  – for the entrance gates
#define GATE_CLOSED_ANGLE_1 10   //change as you wish – for the entrance gates
#define GATE_OPEN_ANGLE_2 90     //change as you wish – for the exit gates
#define GATE_CLOSED_ANGLE_2 10   //change as you wish – for the exit gates
#define NUM_SENSORS 6            // two sensors per track, one left and one right of the gate.  Change to match the number of tracks in your crossing
Then change this next line to match.  One track (2,3) Two tracks (2,3,4,5)  Three tracks leave it as it is..

byte sensor_pin[NUM_SENSORS] = { 2, 3, 4, 5, 6, 7 };  // sensor “OUT” wires connect to these pins.

 

 

 

Scroll to top