Space Invaders Button

April 13, 2009

in Projects

The reason I started all this microcontroller stuff was that I wanted to create an animated button displaying space invaders characters. Preferably the same size as an normal button (the ones you put on your jacket, not your panel).
Now here it is:

If you do not see the electronics for this small display read on after the click. And no, I will not stop tinkering.

Update: You can get your own Blinken Button (aka Space Invaders Button).

The whole project was inspired by Alex, especially his LED matrix projector and his tiny 64 pixel project. After some beers with Alex I claimed: “I can do it much smaller in SMT”. Silly me! Not that it was hard enough to build it in SMT, but I also wanted to do it in bi-color (I just got some small bi-color LED matrix laying around, waiting for a project) and I made some real design mistakes (but that is a story for another article). Additionally I wanted an design which still allows me to use the LEDs of the display as light sensor. That was nearly too much – but only nearly!

To give you an imagination how it will look like lets take a look at a video:

At the end I attached a fixing pin at the battery holder, to wear it as a ‘real’ button:

My girlfriend loves it! Of course she got some special animations and texts.


After some research I choose the ATmega164P as platform. It had enough input pins to drive all the 24 pins of the matrix and still some spare for programmer. The current is supplied to the rows by a transistor (a conveniently prebiased one: DDTC123TUA, it comes with an built in base resistor), the ATmega controls the column diodes by sinking its current. In the I came up with an very simple schematics:

Space Invaders Button

The port usage and layout of the connection was optimized for easy PCB layout. I decided to do all the mapping in software.


If you layout on an PCB, you end up with some real trouble, but it ends up in something like this:

It dimension are a bit smaller than the matrix. It features a nice little SMT switch (C&K Components AYZ0102AGRLC ) on the edge of the board. As you can see the SOT323 format is perfectly small. The current limiting resistors are 4*0402 arrays. The decoupling capacitors are 0402 SMT capacitors. And the PCB is still dirty from flux and solder spots.

This is the whole unit in comparison to an one Euro coin:


The implementation is basing heavily on the code of Alex’ 64 pixel project. But instead of rendering a bit buffer I used an buffer which contained all pin settings (so 4 bytes for PORTA to PORTD).During load time of an sprite its bits are converted into the various port configurations. This allows me to use an really fast update routine of about 800 Hz.This reduces massively any flicker (which is critical if you want to go dancing with the button on).

Beside from that, and some real mistakes it is nothing special. Therefore no code posting here. You can find it on Alex’ site.


Avoid 0402 capacitors whenever you can. They are just too small. And if you use them never place vias in the pads. Since the vias suck up the solder and the capacitor stands up, literally. I ended up with more than one capacitor going 90°.

The 4*0402 resistor arrays are great. You need an hot air rework station to solder them, but they are easy to solder and in an very convenient package. I just stock up on them – they are really nice!

The SOT323 transistor package is perfect for small signal transistors. It is considerably smaller than SOT23 or TO92 and still quite easy to solder. This will be my preferred transistor packaging!

The pre-biased transistors are neither very handy nor very practical. But they are expensive, you have to choose the biasing resistor wisely and always order the wrong parts. There would have been some space for some resistors left – so no real reason to use the pre-biased stuff. I will never use them again.