IR Controlled Lego Duplo Compatible Motorized Locomotive




Introduction: IR Controlled Lego Duplo Compatible Motorized Locomotive

As a busy dad, I enjoy playing with my kids while watching football games. It'll be nice if I could control the toys with the same TV remote without taking eyes off the screen.

This 3D printed IR controlled Lego Duplo Compatible locomotive can be remotely controlled by most of the IR remote controllers such as those come with your TV or DVD player, as well as ones included in the popular Arduino IR kit.

The entire train is made of plastics with 3D printed parts by regular FDM 3D printers. I used PLA plastics which is suitable for toys.

With the IR control functions, you can start/stop the train, change the speed and direction, and turn the headlight on and off.

The software (Arduino sketch) has 4 levels of speed controls in both directions, and allows the train to 'soft start' when take off or changing directions to prevent the train from sudden acceleration and make it safe to play.

In this instructable I will walk you through:

  1. Arduino and IR function hardware
  2. Arduino motor controller hardware
  3. Implementation of the train functions

Step 1: Make the Locomotive

The detailed steps for basic train assembly are available in the previously published instructable can be found here. However, we need to make some changes in the locomotive middle section as well as adding some additional parts in order to accommodate the new electronics. Also, the locomotive needs to be powered by 4 AA batteries. You may use a commercially available battery holder, or print your own. The extra STL files for 3D printing are in the attachment and are available on the Thingiverse at here.

The new parts are:

  • IR receiver base
  • Switch base with buzzer
  • Arduino Nano and HG7881 (L9110S) Dual Channel Motor Driver Module bracket
  • 4 x AA battery holder
  • New train middle section with the access the mini USB port on the Arduino Nano

Step 2: Electronics

  • Arduino Nano and USB cable
  • HG7881 (L9110S) Dual Channel Motor Driver Module (one channel is used in this project)
  • Infrared receiver module VS1838B or equivalent
  • 5V 12mm diameter active buzzer (Make sure it's active buzzer which can generate tones by itself. Do not use the passive buzzer which has to be driven by the Arduino to make tones).
  • Battery clips

Step 3: Assembly

Wire the electronics according to the circuit diagram above.

  • IR sensor: Pin1-> D2, Pin 2 ->GND, Pin 3 -> 3.3V
  • LED: Positive -> D3
  • Buzzer: Positive -> D4
  • L9110S: IA -> D10, IB -> D11, VDD -> Battery (+), GND ->Battery (-)
  • Arduino Nano: VIN -> Battery (+), GND ->Battery (-)

Step 4: Get the IR Remote Control IRLib2 Library

Go to the IRLib2 library link, download and install the IRLib2 A Library for Receiving, Decoding and Sending Infrared Signals Using Arduino. Make sure the library should be installed as follows:

  • arduino/libraries/IRLib2
  • arduino/libraries/IRLibFreq
  • arduino/libraries/IRLibProtocols
  • arduino/libraries/IRLibRecv
  • arduino/libraries/IRLibRecvPCI

Step 5: Get Hexadecimal Values of Remote Keys

1.Upload the attached Arduino sketch to the Arduino Nano

2.Open the serial monitor.

3.Press different remote keys and obtain their hexadecimal values.(Note that the values will not be obtained with 0x which represents hexadecimal).

I decided to use a VIZIO TV remote control laying around with nice rubber keys. Here I have obtained the values of the Forward, Backward, Okay and Green keys which are

  • Forward=0x20DF12ED
  • Backward=0x20DFE21D
  • Okay=0x20DF22DD
  • Green=0x20DF4AB5

These values of these buttons are mapped to move forward, move backward, start/stop change the direction and turn on/off the headlight respectively. Copy the IR code to the Arduino sketch with corresponding functions.

Step 6: Final Assembly and Programming

Carefully put the finalized circuit into the train body, and upload the code to the Arduino Nano. Install the IR receiver module on top of the train cabin and fix it using the 3D printed IR base.

The software has soft start function which will prevent training from sudden acceleration to full speed. There 4 speed levels, and the train will start from lowest speed level from stationary or every time when changing the direction. It will step to the next speed level each time when the forward/backward key is pressed. The buzzer will double-beep when the train starts and will produce a single beep when reached highest speed.

Make It Move Contest 2017

Participated in the
Make It Move Contest 2017

Lazy Life Challenge

Participated in the
Lazy Life Challenge

Plastics Contest

Participated in the
Plastics Contest

Be the First to Share


    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge
    • Make It Bridge

      Make It Bridge
    • Big and Small Contest

      Big and Small Contest