I have a confession to make. I’m an LED addict. If it involves making some blinkenlights I’m your man. In 2010 I helped build the Illuminatrix, a 4ft x 4ft wall of LEDs nestled inside ping pong balls that displayed hundreds of animations from people all around the world. This was my first big electronics project, besides a few kits I’d built and some awful attempts at implementing various audio syntheziser circuits I had found online. But I officially caught the hacker bug back then and that project inspired a lot of my work over the last few years.
This year we decided to build another project for the Burning Man festival. We’re calling it the Diodome and its an 18ft geodesic dome containing hundreds of LEDs. Obviously.
I’ll be detailing the build on my blog as we go, but the first step is to figure out how we’re going to control all these LEDs!
To get started we first had to compile Node for the pi, this turned out to be pretty simple.
This will take a long long time…for me almost 2 full hours. It should however go without a hitch. You can check its working by doing:
Now that Node is running on the pi we’ll need to figure out how to control the LEDs from node…
Obviously an Arduino isn’t powerful enough to run our animation code in Node, so we’ll use the Raspberry Pi and then talk to the Arduino over the USB port. Thankfully the Arduino can talk to a Raspberry Pi using Serial over USB. All we need is to be able to write to the serial port from Node. Thankfully this is quite simple using the
node-serialport library. Here’s a simple bit of code that opens up a serial port to the arduino and sends an array of color values for 5 LEDs.
var serialport = require("serialport"),
We can then write a simple sketch on the Arduino to read from the serial port, and set the color of the LEDs using the excellent NeoPixel library from Adafruit. This library has some rather excellent assembly code that can manage the accurate timing needed for the WS2811 drivers, and even manage to drive the LEDs at 800khz which gives us just enough time to update all our LEDs without any flicker. Here’s the sketch I’m using on my Arduino Micro:
// include the neo pixel library
And there you have it. Simply program your Arduino with this sketch, plug it into your Raspberry Pi, then run the node script with
node app and your LEDs should change color to the values specified (in the example above this was 1st LED RED, last LED blue, all others off).
Next time I’ll be detailing how I setup the animation editor, and how we got the animations running on Node on the Pi using the Tween.js library. If you find this post useful, or are just feeling generous we’re fundraising for the Diodome project now.