The Pico-Controlled Automated Model Railroad builds on his ‘sensored’ track concept that detects a train passing and instructs it to speed up, slow down, or come to a halt. “Electric motors are among my most favourite devices because they connect the fields of electronics and mechanics,” he reveals. “I try to add motors wherever possible.”
As someone with experience of Arduino, Kushagra believes Pico has great crossover appeal, lauding its ease of use and functionality: “One of the best reasons to [use Pico] is the availability of libraries to allow the integration of modules, sensors, and other complex stuff without having to write the entire code from scratch,” he explains in his guide to programming Raspberry Pi Pico with the Arduino IDE.
The project joins Kushagra’s sizable collection of Instructables focused on using microcontrollers and stepper motors to augment a model railway layout. His projects work well together, with this first foray into Pico territory building on Kushagra’s existing ideas for using Arduino to add smart features to his train tracks. “Raspberry Pi Pico helped make it more budget-friendly and enabled several options for expansion in the future,” he says.
Automating a model railroad with Raspberry Pi
Kushagra’s approach to automating a model railway starts with a basic oval track layout, Raspberry Pi Pico, and an L298N motor driver, which he favours because of its +/- 5 V on-board voltage regulator, which can be used to supply power to any attached microcontroller and other modules. “The voltage level is quite important as a lot of sensors and modules use 3.3 volts for communication, and having a 3.3-volt microcontroller eliminates the need of using voltage level shifters and optocouplers in the circuit,” he explains.
Raspberry Pi Pico is programmed using the Arduino IDE and becomes the brains of the model railway, using sensors to instruct each locomotive that passes over the smart track what to do next. As the layout grows, additional sensors can be added and used to alter the locomotive’s speed or get it to stop for a preset time, as if it were at a red signal or at a station. Kushagra says, “I am planning to add yard shunting operation which will allow the locomotive to couple, and decouple, with the rolling stock to allow it to pick them up from one point and drop them off at another.”
Setup Pico to control a model railroad
The setup instructions given on his Instructable are admirably clear, but Kushagra also provides troubleshooting tips for this and his other projects, such as what to do if the train unexpectedly starts moving in the wrong direction (switch the polarity of the track’s power). For example, the sensor’s LED should only light up when a train passes over the sensor-enabled track. If, however, the LED on the sensor is always on, you should adjust the sensitivity of the potentiometer.
Although there are lots of other Raspberry Pi- and Arduino-controlled layouts out there, we really like Kushagra’s low-cost approach to automating his model railway. His modular approach makes it clear enough for newbie makers to take on, while also being ideal for established railway modellers to use as a template to retrofit their layout. “Given enough time and effort, you could automate switching operations, automate the operation of multiple trains at the same time, control the lighting, or use WiFi or Bluetooth to control your trains and turnouts and a lot more,” Kushagra enthuses.
There’s plenty of potential in the ‘sensored’ track approach, too: anyone up for combining the track sensor with a station announcement board to indicate an approaching service (or delay)?