It was an eventful weekend. I built a new prototype rig from an Arduino Mega2560 (the very same Mega that was in my Anthrolume 1.0 suit), because I was going to run out of I/O pins on the Arduino Uno after adding the hand controller, mode LEDs, and XBee radio. Additionally, the Mega has 8KB of RAM, enough that I can keep a record of the colors of all the LEDs in memory, which facilitates some features I want such as drawing moving text across my body.
One of the technical hurdles for Anthrolume 2.0 was figuring out how to use an SD card reader and CoolNeon lights at the same time. The problem lies in the fact that they both want to use the SPI (Small Peripheral Interface) bus on the Arduino, but the CoolNeon lights sort of want that whole bus for themselves.
I designed some digital logic using tri-state buffers that would allow me to switch the SPI bus between the SD card reader and the light strand under the control of one digital pin on the Arduino. But I didn’t really want to add that logic wart if I could find another way.
The “other way” is to hook the light strand to a couple other digital pins and “fake” the SPI protocol. “Faking it” in this case is a technique called “bit-banging.” The idea is that you simulate a protocol (in this case a simple clock-line/data-line setup) by manually setting the logic state of a couple Arduino pins very quickly.
On Sunday I got this approach to work. It allows me to read from the SD card using SPI and write to the LED strand manually via bit-banging. At first I found bit-banging to be quite a bit slower than the hardware-accelerated SPI provided by the Arduino, but by using the badass digitalWriteFast library I was able to achieve frame rates of 95 fps with 50 LEDs. That will give me up to 40fps for my production strand of 250 LEDs – easily enough.
I wrote a very simple C# program to emit two pre-canned animations to files. The files consist of RGB tuples x 50 LEDs x some number of frames. Later I’ll beef up the .ani files to include metadata, musical synchronization information, etc. I used that program to write two 37K animation files to an SD card and loaded that SD card into the Arduino’s external SD card adapter.
The video below demonstrates me reading animation frames from the SD card and streaming them to the strand in real time. This is a big technical milestone for Anthrolume 2.0!