Facebook Pixel Running Model Trains Without Human Input | Circuit Cellar - education - Read this story on Magzter.com
Go Unlimited with Magzter GOLD

Go Unlimited with Magzter GOLD

Get unlimited access to 10,000+ magazines, newspapers and Premium stories for just

$149.99
 
$74.99/Year

Try GOLD - Free

Running Model Trains Without Human Input

Circuit Cellar

|

March 2026

A Raspberry Pi Pico Controls Two Trains

- By Mike Christle

Running Model Trains Without Human Input

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?

imageSYSTEM REQUIREMENTS

I 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.

MORE STORIES FROM Circuit Cellar

Circuit Cellar

Circuit Cellar

IDES Converge Toward VS Code

Your Next IDE Might Look Very Familiar

time to read

12 mins

April 2026

Circuit Cellar

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.

time to read

2 mins

April 2026

Circuit Cellar

Circuit Cellar

Wireless Convergence Reshaping Autonomous Transportation

The future of transportation will not be defined by a single technology milestone.

time to read

4 mins

April 2026

Circuit Cellar

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.

time to read

1 min

April 2026

Circuit Cellar

Circuit Cellar

Datasheet: Haptic Components Things That Go Buzz in the App

Haptic Devices Bring Physical Feedback to the Human Interface

time to read

7 mins

April 2026

Circuit Cellar

Circuit Cellar

Software-Defined Systems

Reshaping the Future of Modern Cars

time to read

7 mins

April 2026

Circuit Cellar

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.

time to read

1 mins

April 2026

Circuit Cellar

Circuit Cellar

B MCU Real-Time Tracing

How to Trace MCU Code in (Almost) Real Time

time to read

13 mins

April 2026

Circuit Cellar

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.

time to read

8 mins

April 2026

Circuit Cellar

Circuit Cellar

A Tribute to Robert Tinney

A Captivating Artist in the Early Days of Circuit Cellar

time to read

3 mins

April 2026

Listen

Translate

Share

-
+

Change font size