Blinken Button meets SPI

At the 27C3, Gabe and I met Marcus from Interactive Matter, who sold these nifty Blinken Button kits. Basically it’s a wearable 8x8 LED display:

Blinken Button for Beginners

The button displays a series of random animations, which comes programmed into the ATmega168 microcontroller. Now we thought it would be cool if we could use the button as a more general purpose display device. That would allow us to hook up some sensors and set the display according to the sensor input. To do this, we needed some way of communicating with the button from another microcontroller.

Enter SPI - the Serial Peripheral Interface Bus. SPI is a full duplex bus which allows two or more microcontrollers to communicate. Basically the bus is controlled by the bus master, who is decide which slave is allowed to send data, and when. Each slave then waits for its Slave Select (SS) pin to become low, before it can send and receive any data.

On AVRs, the ISP pins are used for SPI, which were already broken out on the Blinken Button. Since the SPI master decides when data is sent over the bus, it made sense that the Blinken Button should be configured as a slave and update its display whenever data was sent to it. Unfortunately the SS pin (PB2) was not broken out on the button, and was not used. At the congress we worked around this issue by having the button act as a master, and continuously poll the slave for new frames to display. Although this worked, it wasn’t an good solution and required extra book-keeping on the other end as well as consuming more power.

In order to improve on the design, I decided to attempt to bring out the SS pin and make it accessible through a wire. Being SMD and all, this was easier said than done. After tinkering for a while and probing the tiny pins making sure there were no shorts, I succeeded in soldering a tiny wire to the pin. Some glue was added to make sure any tension didn’t break the connection. Below is the result:

Blinken Button SPI

Blinken Button SPI

Although it might have worked to just short the pin to ground, limiting the bus to a single slave, I decided to bring it out instead.

Then it was fairly straightforward to adapt our previous code to the new slave configuration, and merge it with the original display code. The code for the SPI-enabled Blinken Button can be found on GitHub. It also includes example code for an SPI master controller. It works perfectly from my STK500 with an ATmega8535 as master :-) And with a logic level converter (or 3.3V Arduino), it should work with an Arduino as well.

It would be awesome to see future versions of the button with the SS pin brought out on the PCB, even as an optional feature :)

That’s all, happy hacking!