Lego train revisited

General idea for a new train controller!

The idea is to have each train equiped with the following:

Arduino Nano

NRF204 Wireless transmitter

Infrared Emitter

The IR emitter will be put on the engine part and taped of so signals only get send to the local train. Lights are an option too of course. This way we can equip each train with it’s own unique NRF address and forget the whole Lego Power Functions channels and colors because the IR will only reach the one train.

On the Nano there will the NRF library, I like the RF24 library because of its ease of use, and the Lego Power Functions library.

One Arduino (also with an NRF will be in control of everything via Blynk app and the local Java server so minimum latency is guaranteed. Because the NRF also supports some sort of broadcast-to-all it’s easy to build in emergency stopping functionality, just in case. In the end this will probably be a Mega, but for now an UNO will probably be enough. This one will be connected via Ethernet (ENC28J60 SPI module).

Detection of the trains can be with reed contacts. This probably is the cheapest solution hardware-wise but you need to write a lot of software for that. Currently I’m investigating color-sensors. They have a tiny CCD with just a couple pixels for color detection. The huge advantage of this method is you can label each train at the bottom with unique colored bricks and have separate colors for different types of cars. You can measure length and direction of the train probably really easy:

ICE-LOC <> WAGON1 <> WAGON2 <> ICE-Close

(green) (blue) (blue) (red)


(purple) (yellow) (yellow) (red)

In this example we can differentiate between the freight train and passenger train and the start and end of the train. We can do all sorts of good stuff with this setup. For example have the passenger train get a higher priority, slow down the freight train at the station, read the train length etc.

Anyway, so far for the theory, we should put this in practice now, hopefully I’ll be able to show you some progress soon-ish. 🙂