Building projects with programmable LEDs can be very satisfying. With a few lines of code, you can create an awesome animated pattern of light. If you’ve programmed with an Arduino, you certainly remember the first time you got an LED to blink! From there, you probably wanted to go larger. Arduino is an excellent platform for projects with a small number of LEDs, but at a certain point the small micro-controller reaches its limit.
FadeCandy is an alternative way to drive potentially thousands of LEDs, and is an excellent way to go when you have a project larger than Arduino can handle. FadeCandy also provides sophisticated techniques to make your animations buttery smooth—very important when you aren’t going for a “chunky” look with your lighting. A typical problem when using LEDs is getting a smooth fade to off or a low brightness. Usually there’s a pronounced “stair step” or chunkiness as the LED approaches minimum brightness. The FadeCandy board uses dithering and interpolation to smooth between color values, giving you more nuanced color and smoother animation. With FadeCandy, your light palette can now include “subtle and smooth” as well as “blinky and bright.”
Two FadeCandy boards
The FadeCandy board connects to your computer over USB and can drive up to 8 strips of 64 LEDs. FadeCandy uses the popular WS281x RGB LEDs, which are available online, for example, NeoPixels from Adafruit. Multiple boards can be connected to the host computer, and with 512 LEDs per board, you can create quite large light projects! The host computer runs a piece of software called the FadeCandy server (fcserver). The program (called the “client”) that creates the light pattern is separate from the server and can be written in a variety of different programming languages. For example, you can write your animation program in Processing and your Processing sketch will send the colors for the pixels to the FadeCandy server, which sends the data over USB to the FadeCandy hardware boards. It’s also possible to make a web page that connects to the FadeCandy server, or to use Python or Node.js. This flexibility means that you can use a powerful desktop programming language that supports, for example, video playback or camera processing. The downside is that you need a host computer with a USB to drive the FadeCandy hardware boards, but the host computer could be a small one, such as the Raspberry Pi.
FadeCandy connected to computer via USB and an LED strip via a breadboard. The LED strip is connected to a separate 5V power supply (not shown).
When using a small number of LEDs with an Arduino, you can get away with powering the LEDs from the same power supply as the Arduino. Since FadeCandy is designed to use a large number of LEDs at once, you’ll need a separate power supply to power the LEDs (you can’t just power them from the USB connection). This is actually a good thing, since it makes you think about providing enough juice to run all the LEDs. For a full guide on setting up a FadeCandy board and software, I recommend the in-depth tutorial LED Art with FadeCandy.
Once you have the hardware set up, there are two pieces of software you need to run. The first is the FadeCandy server (fcserver). The server connects to the FadeCandy boards over USB and listens for clients to connect over the network. The client software is responsible for generating the pixels that you want to show and then passing this data to the server. The client software is where you create your fancy animation, handle user interaction, analyze audio, or do whatever processing is needed to generate the colors for your LEDs.
Client program in Processing
Let’s look at one of the examples included with the FadeCandy source code. The example is written in Processing and plays back an animation of fire on a strip of 64 LEDs. The Processing code loads a picture of flames and scrolls the image vertically over the strip of LEDs. The white dots in the screenshot represent the LEDs in the strip—at each of the dots, the color from the Processing sketch is sampled and sent to the corresponding LED. The nice thing about using Processing to make the animation is that it’s easy to load an image or perform other more complicated operations and we get to see what’s happening onscreen. With the large amount of memory and CPU on a laptop computer, we could also load a video of a fire burning and have that show on the LEDs.
The light from the LEDs in this example is quite pleasing. Projected on a wall or other surface, the light ripples smoothly. It’s possible to turn off the dithering and interpolation that FadeCandy provides (for example, with this Python config utility) and you can see that these techniques do lead to smoother animation, especially at lower brightness levels. With the dithering and interpolation turned on, the motion is more fluid, giving more of an illusion of continuous movement rather than individual LEDs changing.
The choice of using FadeCandy or Arduino to control LEDs comes down largely to a question of scale. For projects using a small number of LEDs, using an Arduino makes it easy to make the project standalone and run on battery power. For example, in my Chrysalis light sculpture, I use an Arduino to drive 32 LEDs interpolating between colors from an image. I was able to fit the image into the onboard memory of the Arduino by making it quite small (31×16 RGB pixels, for a grand total of 1,488 bytes). Getting smooth fading with 32 LEDs on an Arduino is certainly possible, but using hundreds of LEDs would be out of the question.
FadeCandy-driven LEDs in a Polycon light sculpture.
FadeCandy was designed for projects that are too big to fit on a single Arduino. Where the total memory on an Arduino is measured in kilobytes, the RAM on a Raspberry Pi is hundreds of megabytes, and on a laptop you’re talking gigabytes. You can use the processing power of your laptop (or single board computer) to analyze audio, play back video, or do heavy computation that would be hard on a microcontroller. By providing easy interfacing and smooth fading, FadeCandy really opens up what is possible for artistic expression with programmable lighting. I for one welcome the new age of buttery smooth LED light art!
About the author:
Michael Ang is a Berlin-based artist and engineer working at the intersection of art, engineering, and the natural world. His latest project is the Polygon Construction Kit, a toolkit that bridges the virtual and physical realms by constructing real-world objects from simple 3D models. He is one of the organizers of Art Hack Day, an event for hackers whose medium is tech and artists whose medium is technology.
Into Arduino? Check out our Arduino page for our newest and most popular releases. Begin your adventure through creative hardware today!