Crossing Signals - Part 3 of 4 - Designing the Circuit

As alluded to in Part 2 of 4 of this series of posts, I used an Arduino Pro Mini to handle the detection of trains and activation of the flashing crossing lights. On September 21, 2021 I discussed a handy tool for drawing wiring diagrams for Arduino circuits. Following is such a wiring diagram showing the wiring of my crossing light circuit on a breadboard. A breadboard is a device into which various electronic components can be plugged without the need to solder the components. This allows for the inevitable tinkering that is required in the design and testing of a circuit. Once one is satisfied with the circuit, a more permanent circuit can be created by soldering the various components together to create the final circuit.


The above diagram shows an Arduino UNO in the circuit. I used an Arduino Pro Mini in my final circuit because it is much smaller (width is about the size of a quarter-dollar coin) and cheaper but it has the same terminals and processing capacity as the UNO.

Note that the photoresistors are wired in series in pairs labelled 1 through 5. Following is a sketch showing which sensors on my model railroad correspond to those in the wiring diagram:


You will note that each pair of photoresistors are those that are physically closest to one another. While the lighting of my layout is fairly uniform, there are likely subtle differences in lighting that are not easily detectable with the naked eye (or even an eye with its clothes on!). As described in Part 2 of 4 in this series, photoresistors are linear devices that vary their amount of resistance to electrical current depending on how much light does or does not fall on them. I wanted the amount of light falling on each pair of photoresistors to be as consistent as possible because the Arduino detects the presence of rolling stock by comparing the amount of current running through each pair of photoresistors when fully lit against the amount of current when shaded by rolling stock.

Please note that I have not always been consistent with my terminology. My use of the words "sensor" and "photoresistor" mean the same thing.

In Part 4 of 4 of this series I will share the Arduino C++ code used to operate this circuit. I used the above breadboard configuration as I tinkered with the logic to make the crossing lights flash as I wanted them to. Once I was satisfied that the circuit behaved as I wanted it to, I recreated the circuit by soldering components to a PC board that is configured the same way as a breadboard. The following are two photos of the final product taken from two sides.


The green, yellow, orange, red and brown wires are those that go to the photoresistor pairs.

The blue, purple, grey, white and black wires all go from the positive side of the circuit to the photoresistor pairs.

The black and red wires (on the left in the first photo and on the right in the second photo) are from the 12 volt DC accessory buss under my layout. The little silver device is an L7805 voltage regulator which converts the 12 volts DC to the 5 volts DC which the Arduino needs to operate. In the first schematic of this blog post, the graphic shows a USB cord that supplies the 5 volts DC coming from the USB port of a computer. This voltage regulator takes the place of the USB cord. Following is a diagram from the Internet showing how to wire such a voltage regulator: