I found a few code examples floating around the 'net for controlling an LED cube. They all required large arrays of binary or hex data to control the LEDs. I figured there must be an easier way so I set out to write my own software.
My first decision was to make the software mirror the hardware. That meant addressing each LED by column and level instead of using raw port data or the traditional x, y, z. The second decision was to start with basic functions, like turning a single light on or off, and building up from there.
Lastly I decided to introduce two features which are useful for more interesting effects. One is a buffer which allows the basic functions to build up more complex patterns. The other is a sequence function which lights an array of LEDs one at a time, or all at once.
The library started as procedural code and loose functions. From there it was very easy to follow the tutorial
to create a reusable Arduino library.
Be sure to download the library
and unzip it to sketchbook/libraries
. If set up correctly you should find an example in the Arduino software under File > Examples > LedCube > ledcube
The code is also available on Github at gzip/arduino-ledcube
Thanks for reading!