LEGO PF-trains controlled with Arduino

To control the trains the transmitter is based on a developmentboard Arduino with an ARM-processer, 328.

First of all I need to control 1 train, because there was nothing available yet for R2R.

I discovered the speed-up and speed-down function was not there. So the function SingleOutput was modified to provide those two modes.

Then expand the program to 4 trains for the four IR-channels and the engines connected to the RED-connector. The BLUE one is optionally used for frontligths and cabinligths.


Programcode for controlling 4 trains (4 channels on RED) and lights on the BLUE-part.

Programcode for controlling 8 trains (4 channels on RED + BLUE)



2 buttons for speed-up and slowdown (pushed together lights on/off)

1 button for STOP all trains

1 button for selecting the IR-channel 1- 4

1 button for a normal looking slowdown of a train when approaching a station or signpost.


To develop:

Train-identification and feedback to Arduino

Bluetooth to Arduino with connection to Windows-phone or Android-phone.

IR-receiver for universal remotecontrol, so Arduino acts as an intermediate. A kind of this control is made with PFdroid.

Servo’s added to handle the rail-switches.

A pole with a bunch of IR-LEDs to control the area. The LEDs are connected to transistors because the fan-out of Arduino cannot support them in one time.



Needed hardware:

Arduino Uno rev3

Some pushbuttons with pull-down resistors (5-33kOhm)

7 segment LED-display connected to 4511 (hex to 7segment)

1 IR-led 940nm


I found some info on the internet on and on Github.

Main source was from “supercow” what I used as input for my program.



1 train controlled by Arduino (fully operational)

4 trains controlled by Arduino (fully operational)

8 trains controlled by Arduino (just under construction)






Related links:


Adriaans github
Know Total Visits


Mail: pe1odf at-sign

This is another project from RJVJ-Disco-Productions    2-2015