On almost every model railway there is at least one place where road and rail cross. If prototype practice is to be followed, some way of making the crossing safe is needed.
There are several ways of doing this, including gates, booms and crossing lights.
Modelling gates is fairly simple, as they are available as plastic kits, but making them operate is quite difficult, as complex gearing is needed.
Operating booms have been approached in several different ways. The simplest uses the weight of the train pressing on a small bar under the track to mechanically hold down the booms. The main problems with this system are that the booms only close when the train is actually on the crossing, and often only the engine is heavy enough to hold them closed.
Booms can also be actuated by solenoids or motors. For the automatic operation of these, sensors will be required to detect the presence of the train.
Flashing crossing lights are another option and these require no mechanics, however they are often used in conjunction with booms.

A close up of the Level Crossing, showing the placement of the components. Note the pins inserted in the PCB are to show where to connect the wires for the external components.

The circuit diagram of the Level Crossing. You may not see the necessity for all the parts. They are needed when the unit is expanded.

This photograph shows a pair of commercial railway crossing signals. They are available at most model railway stores.

The electronics required to alternately flash two lamps is simple. Two-transistor multivibrators are available for around ten dollars. They come in small plastic or epoxy cases and can drive one or two crossing lights but the only way of switching them on and off automatically is to connect them to a spare set of contacts on a relay used in an automatic block signalling circuit.
Presented here is a fully automatic light flashing unit that can detect trains coming from both directions on one track or one direction on each of two tracks. It can be expanded to cover four tracks in both directions.
A crossing bell sound option can be added, as can an operating boom device. The belt sound and boom control do not work well together, as the motor driving the booms creates a lot of electrical noise, especially when driven by a pulse speed controller.
Some people may find a quieter mechanism for driving the booms than the one mentioned in this article. Isolated power supplies and shielding could be used to reduce the noise level. The circuit will be described in several different stages, as each option is made on a separate PC board. The first stage will be the flashing light unit and automatic control. How It works. This unit is based on, the 74C14 Schmitt inverter and a 4013 dual D flip-flop. The operation is quite complex so it will be described in sections. The first section is the train detection circuit. The track sensor is placed on the approach to the crossing, so that the train will activate it before it arrives at the crossing. Each sensor is an MEL-12 Darlington photo-transistor. The sensitivity can be adjusted using the trimpots that feed the photo-transistor. The output from the junction of these is taken to the input of a Schmitt inverter which is part of an OR gate. When light falls on the MEL-12 it conducts, pulling the input of the Schmitt inverter low. If a train covers the MEL-12 making it dark, it turns off and the input of the Schmitt inverter is pulled high by the trimpot. The output of the MEL-12 photo-transistors are OR gated together by three Schmitt inverters two diodes and a 100K pull-up resistor. This complex type of OR gate was chosen because it had to be easily expandable and have Schmitt inputs. The output of the OR gate is fed into a delay circuit consisting of a diode, a 1M resistor, a 10u electrolytic and a Schmitt inverter, When the output of the OR gate goes high, indicating the presence of a train, the 10u capacitor is charged quickly by the diode. As long as there is a train over either photo-transistor, this capacitor will be held charged through the diode. This will hold the output of the Schmitt inverter in the delay circuit low, thus enabling the oscillator and the second D flip-flop of the 4013.

When the train is no longer over the MEL-12, it switches on and pulls the input of the OR gate low. When both input of the OR gate are low the output will also be low, and the 10u electrolytic will discharge through the 1M resistor. After about 16 seconds the output of the Schmitt inverter in the delay (pin 10) will rise, disable the oscillator end jam the output of the second stage of the 4013 HIGH. This will switch off both output transistors.

Shown here is the PCB track work and the overlay for the Level Crossing.    

The Level Crossing kit 


2 - 1k
2 - 2k2
1 - 10k
1 - 100k
1 - 150k
1 - 1M
2 - 50k mini trim-pot
1 - 2u2 electro
1 - 10u electro
1 - 100u electro
4 - 1N4148 diodes
2 - BD140 transistors
2 - Mel 12 Darlington transistors
1 - CD40106 or 74C14
1 - CD4013
2 - 14 pin IC sockets

All components of the level crossing project except for the MEL-12 photo-transistors are mounted on a 4cm x 8.5cm PC board. Check that the trim-pot leads will fit down the holes on the PC board. If not, enlarge them. Solder in the links first, then the diodes and resistors. Next solder the IC sockets. The usual care should be taken with the orientation of the electrolytics.
The BD140 transistors are mounted with their metal faces toward the edge of the PC board. Solder in the metal trimpots and the insert the ICís.
You can now test and adjust the unit. Solder in the MEL-12 photo-transistors as shown in the photograph. The base leads may be cut short as they are not used. Wire a lamp to each output and connect the unit to 12 volts. This unit has no diode protection so care must be taken with polarity.
Place the unit in an area that is lit similarly to your model railway. Set both trim-pots to the centre of their travel. Cover one of the photo-transistors. The lights should start flashing. If they don't, adjust the corresponding trim-pot until they do. Uncover the photo-transistor. After about fifteen seconds the lights should stop flashing. If they don't t, try the adjustment again. The adjustment for the second photo-transistor is the same. To make adjustment easier, the 10u electrolytic can be temporarily removed from the delay circuit. The unit will require a final adjustment when mounted on the layout.
Four lamps can be driven off each output because medium power transistors have been used. They will not be in continuous use so heat-sinks are not necessary.
The MEL-12 photo transistors are set between the sleepers of the track If there is not enough ambient light, mount a street light near the photo-transistor.
A photo-transistor is needed only in the approach to the crossing, as the delay will allow enough time for the train to pass before the lamps stop flashing. If the trains travel along the track in both directions, a photo-transistor will be needed on both sides of the crossing There should be 15 to 30cm gap between the crossing and the photo-transistor, depending both on scale and the speed at which the train will travel.
The unit is not limited to spanning one bidirectional track or two single direction tracks. The next circuit Crossing Expansion, allows it to span four bidirectional tracks.

The MEL12 sensors are placed on either side of the Level Crossing if bidirectional traffic travels along the track. The distance between the sensor and the Level Crossing should be between 15 and 30cm.
If the train travels along the track in one direction, only one sensor is needed as the delay in the circuit will allow enough time for the train to pass.