Robert C. Martin (Uncle Bob) said in a talk:

Imagine you have a button that you can push, it will test your code and if everything is working a green light will come up, but if something is broken, a red light will come up […]

He was of course talking about TDD. I got inspired to build this little toy.

Hardware schematics, firmware and host software is available in this Github repo. Along with information on how to compile and use.

This is a physical toy traffic light to be used with software development TDD (and testing in general) tools. It will not boost your productivity nor make you a better programmer or TDD practitioner, but it looks cool :)

Lets explain how it works, it’s very simple:


The atmega328p AVR microcontroller is very popular and cheap, but if you buy them on Ebay for example, chances are it comes with an Arduino bootloader, which gets in the way because we can perfectly use the internal oscillator instead of an external 16Mhz crystal. So the first thing to do is change the fuses to the default ones:

# avrdude -p m328p -c usbasp -U lfuse:w:0x62:m -U hfuse:w:0xd9:m

Now we are using the internal 1MHz oscillator, perfect!

I don’t have a PCB yet (although it should be pretty easy as I made the circuit schematic using kicad) but the circuit is small and simple so it’s easy to build it with prototype PCB. Additionally I added some small neodymium magnets in the back to stick it easily close to my monitors.


The firmware is no more than UART boilerplate with 4800 baud rate so it is stable with at 1MHz clock speed.

The main loop will wait for a command r, y or g and turn on the pin corresponding to the color LED.

Notice how if another character is received the output is cleared so all the LEDs are off.

The host software configures the serial port with a 4800 baud rate:

From then controlling the LEDs is as simple as

Find more information about how to use it in the Github repo.