Toy Traffic Light with Arduino and Lego Duplo

Demoing this to my son

Here is my small project that I made for my son’s 2nd birthday.

He is very fond of trains and cars, so I thought that a working traffic light would not hurt. I know there are some commercially produced toys, but I wanted to do something myself.

If you have religious feelings about Lego, proceed with caution – some damaging images ahead.

Concept

I just looked at a 2x4 regular Duplo block and thought that its bottom tubes resembled the traffic light tubes (kind of).

Those tubes also large and deep enough to accomodate regular 5mm LEDs.

However to place the Arduino and have some space for the wiring, I had to cut almost entirely the two and a half tubes with a Dremmel rotary bit. Even after this the block still has some rigidity:

Videos

How not to solder:

Almost ready:

Complete:

Parts

Project is based on Arduino Nano which fits pretty well inside the regular Duplo block.

  • Arduino Nano V3
  • Red, Green, Yellow LEDs
  • 220 Ohm resistor (3x, for the LEDs)
  • Pushbutton
  • Battery block

Power

One can use pretty much anything to power Arduino Nano with some LEDs. I had some CR2032s, 9v crown, Li-Ion 18650 and an 3xAAA battery block lying around.

Initially I wanted to go with CR2032 in order to reduce weight and complexity, but the ones that I had did not produce enough current.

18650 is a good choice, but would require more block processing to fit the battery.

So I went with a noname 3xAAA battery pack.

Coding

I started off with a python sketch, aiming to use ESP32 with micropython to allow over-the-air traffic pattern updates.

For some reason I had issues with ESP32 on my laptop (could not properly connect over serial, even with that bespoke UART driver).

So I went really simple, with a regular Arduino and C.

Wiring

Assembly

Soldering is really messy, but also the space was limited:

I’m as surprised as you are with my soldering:

Some drilling had to be applied:

Complete with some hot glue:

Send
2020   arduino   DIY   family   hardware   lego   projects   source-code   toy