✅ To build any of the LEGO trains in this video, check out https://eggybricks.com !
Become a patron to get quarterly paper goods by mail, video shoutouts, and our undying gratitude!! https://patreon.com/eggybricks 🍳
All the code to run this on your own layout, without any LEGO train crashes, is up at: https://github.com/eggybricks/self-driving-lego-trains
---
ALSO
We made a short guide to how to add a color-and-distance sensor to our LEGO freight trains, but it should work for any other PoweredUp LEGO train (e.g. any recent motorized LEGO train, like 60337): https://github.com/eggybricks/self-driving-lego-trains/blob/main/instructions%20-%20adding%20color-distance%20sensor.pdf
Other stuff shown in this video that you'll need to run everything:
- Pybricks itself: https://pybricks.com/ (the Python version is totally free — only the code blocks are paid)
- @BatteryPoweredBricks x Tom Cook motorized switch: https://rebrickable.com/mocs/MOC-147294/BatteryPoweredBricks/low-profile-switching-machine-mod
These ones are affiliate links, which help support the channel:
- LEGO switch tracks (20% off right now): https://amzn.to/4jDvkBL
- LEGO train tracks: https://amzn.to/3EkhNPn
SECRET OFFER FOR PEOPLE WHO READ THIS FAR:
Instructions for the six microscale cities in this video are FREE at https://eggybricks.com — use coupon code BORIS
---
In this video, we crash five LEGO trains, then try our best to run them on the same track without crashing them. Includes LEGO PoweredUp; Pybricks; A-star, Dijkstra's, and breadth-first pathfinding; some light Python programming; motorized switches switching in sync; LOTS of LEGO trains.
The final automated LEGO train control system handles multiple trains safely, balancing:
- Finding the shortest route (like Google Maps)
- Avoiding conflicts with other trains (like air traffic control)
- Planning reversals when needed
---
chapters:
0:00 the LEGO train control problem
1:57 step 1: control the switches
5:33 step 2: control the trains
9:12 step 3: pathfinding
13:40 step 4: better, faster, stronger
16:43 step 5: all the trains!! traffic control
22:44 CHALLENGE ROUND
train crashes at 0:20, 1:44, and 16:44
lego trains lego train crashes lego train control systems air traffic control how to build lego trains lego MOCs 2025 eggy bricks how to build lego trains air traffic control lego train automation self-driving trains ai trains control tower