Try GOLD - Free
Running Model Trains Without Human Input
Circuit Cellar
|March 2026
A Raspberry Pi Pico Controls Two Trains
Running two model train sets on a single set of tracks without collisions is fun but exhausting. So Mike programmed a Raspberry Pi Pico and used a Digital Command Control signal, multiple turnout switches, sensors, and control software, to run two trains with no crashes—all without any human intervention. His code and related files are included.
Lately I have been playing with a model train set. To challenge myself, I bought two sets with two engines, four turnouts, and lots of track. My goal was to run both engines at the same time, without crashing. This was fun at first, but after a while I got tired of constantly adjusting speeds and throwing switches. So I finally thought, why should I do all this work, when I can just program a computer to do it all for me?
SYSTEM REQUIREMENTSI want to run two trains—a fast passenger train and a slow freight train. Each will have its own schedule, coordinated with the other so there are no collisions.
To accomplish this, I need four elements. First, I need to drive the Digital Command Control (DCC) signal to power and control the engines. With DCC I can control the trains, control lights, toot the whistle, and have all sorts of fun. Second, I need to control the four turnout switches to control the trains’ routes. Third, I need four sensors to monitor where the trains are on the track. Fourth, I need control software to control the trains and turnouts.
The Raspberry Pi Pico is perfect for this project. I can program the PIO module to handle all the time-critical operations and implement the control software in a powerful, high-level language. I will use the PIO module to drive the DCC signal and pulse the turnout switches. The final PCB is shown in Figure 1.
This story is from the March 2026 edition of Circuit Cellar.
Subscribe to Magzter GOLD to access thousands of curated premium stories, and 10,000+ magazines and newspapers.
Already a subscriber? Sign In
MORE STORIES FROM Circuit Cellar
Circuit Cellar
IDES Converge Toward VS Code
Your Next IDE Might Look Very Familiar
12 mins
April 2026
Circuit Cellar
New KYOCERA AVX Capacitors for Optical Communications
KYOCERA AVX, a leading global manufacturer of advanced electronic components engineered to accelerate technological innovation and build a better future, has expanded its selection of 550/560 Series ultra-broadband capacitors to better satisfy surging cross-market demand for high-speed, high-bandwidth optical communication systems.
2 mins
April 2026
Circuit Cellar
Wireless Convergence Reshaping Autonomous Transportation
The future of transportation will not be defined by a single technology milestone.
4 mins
April 2026
Circuit Cellar
STMicroelectronics' New STM32 Series Redefines Entry-Level Microcontroller Performance and Value for Smart Devices Everywhere
STMicroelectronics (ST), a global semiconductor leader serving customers across the spectrum of electronics applications, has announced a new generation of entry-level microcontrollers (MCUs) to boost the performance of billions of tiny smart devices throughout factories, homes, cities, and infrastructures while meeting cost, size, and power limitations.
1 min
April 2026
Circuit Cellar
Datasheet: Haptic Components Things That Go Buzz in the App
Haptic Devices Bring Physical Feedback to the Human Interface
7 mins
April 2026
Circuit Cellar
Software-Defined Systems
Reshaping the Future of Modern Cars
7 mins
April 2026
Circuit Cellar
Vishay Intertechnology Phototransistor Optocouplers Deliver Accuracy and Energy Efficiency for Industrial Applications
Vishay Intertechnology, Inc. introduced a new series of phototransistor optocouplers that combine a high and linear current transfer ratio (CTR) over temperature with a low forward current of 0.5mA.
1 mins
April 2026
Circuit Cellar
B MCU Real-Time Tracing
How to Trace MCU Code in (Almost) Real Time
13 mins
April 2026
Circuit Cellar
Getting Started with Zephyr RTOS
Sometimes, too much can be just enough. In this article, Jacob shows why learning an RTOS that's more than you need can be just what you need for your growing skillset.
8 mins
April 2026
Circuit Cellar
A Tribute to Robert Tinney
A Captivating Artist in the Early Days of Circuit Cellar
3 mins
April 2026
Listen
Translate
Change font size

