DesignSpark Electrical Logolinkedin
Menu Search
Ask a Question

11 Dec 2018, 15:33

Fun Lighting Effects with a Neopixel Matrix FadeCandy controller

Adding lighting effects to the Red Tin with a Neopixel Matrix and FadeCandy controller.

I had noted that the Designspark Design Challenge this time around is Lights Fantastic and this got me thinking that the Red Tin would definitely benefit from some interesting lighting effects, so I started doing some research into the available options.

Having recently helped with the Leak Killer challenge demonstrator for the RS stand at Electronica, I had come across the Adafruit Dotstar LEDs, so I immediately thought of them. I then discovered the related NeoPixels. Comparing the Dotstar and The Neopixel, I decided the latter would provide the best option, with the added advantage that they come in a variety of interesting form factors.

I then discovered the FadeCandy controller and was particularly intrigued by this. It had been developed for a Burning Man festival lighting project so that immediately appealed to me. Looking at the introductory tutorial it appeared as though the setup was well within my capabilities, but on the other hand, offered the scope to dive in deeper if I wanted.

Installing the necessary software

I got my hands on a FadeCandy (905-4624) and Neopixel NeoMatrix (124-5498) and started following the FadeCandy tutorial on the Adafruit website. It begins by installing Processing, which is the programming language commonly used for controlling the FadeCandy. Scripts for the FadeCandy can also be written in Python, HTML and JavaScript/Node.js, so if you are happier with any of those they are an option also.

The tutorial outlines set up and use with Windows and OS X, but the Processing web site also has downloads and instructions for Linux.

I also needed the FadeCandy software. I downloaded the “Source code .zip” from the Fadecandy Releases GitHub.

The first thing was to get the FadeCandy server running. Again the tutorial provided details for Windows and OS X, but I had to look in FadeCandy Github for instructions for Linux. I found them here.

Running the server with sudo ./fcserver config.json starts it with the default config file. If it is not run as root it generates an error ”Error opening FadeCandy: Access denied (insufficient permissions)”.

With the server running I opened a web browser and navigated to http://localhost:7890, I could see that it was running OK, but that no FadeCandy was connected.

Connecting the FadeCandy and the Neopixel Matrix

Now for some soldering. The NeoPixel Matrix has 2 groups of 3 pins, with 3 marked DOUT, 5V and GND, and the second 3 marked DIN, 5V and DND. I soldered a wire to each of the 5V and the GND in the former group.

I was going to be using a bench power supply initially, so I left the other ends of the wire as they were and later I could solder a suitable socket on to connect to a 5V power supply.

The FadeCandy needs to be connected to GND and DIN, so I soldered a wire to each of those pins, and the other ends of these need to connect to one of the 8 channels on the controller. They are arranged along one edge of the FadeCandy and are labelled + and -. It seemed sensible to connect my NeoPixels to channel 0.

Making Pretty Patterns

With the FadeCandy plugged into a USB socket on the computer, the NeoPixels connected to a 5V power supply and Fadecandy server running on the computer, I could now try running sketches. The “" I had downloaded earlier included some examples.

I initially encountered a problem running the example sketches and they generated an error message. This was solved with the help of this page and was simply a matter of editing the offending line, replacing:




parent.registerMethod("draw", this);

I tried the sample sketches and the ones that reacted to mouse movement were fascinating, but not really what I wanted for a display to accompany music. I often play at events that feature old school liquid wheel projections, so I was looking for something that would compliment that. Ultimately some kind of interactive sound to light effect would be ideal, but I need to learn to walk before I can run.

One of the examples features some randomly generated cloud shapes that use Processing’s noise() function and that seemed to fit the bill. To quote the Processing web site:

“Perlin noise is a random sequence generator producing a more natural, harmonic succession of numbers than that of the standard random() function. It was developed by Ken Perlin in the 1980s and has been used in graphical applications to generate procedural textures, shapes, terrains, and other seemingly organic forms.”

Making some simple tweaks

// A simple example of using Processing's noise() function to draw LED clouds
OPC opc;
PImage clouds;
void setup()
size(500, 500);
colorMode(HSB, 100);
noiseDetail(5, 0.4);

// Render the noise to a smaller image, it's faster than updating the entire window.
clouds = createImage(128, 128, RGB);
opc = new OPC(this, "", 7890);
opc.ledGrid8x8(0, width/2, height/2, height / 8.0, 0, false);
void draw()
float hue = (noise(millis() * 0.0001) * 200) % 100;
float z = millis() * 0.0001;
float dx = millis() * 0.0001;
for (int x=0; x < clouds.width; x++) {
for (int y=0; y < clouds.height; y++) {
float n = 500 * (noise(dx + x * 0.01, y * 0.01, z) - 0.4);
color c = color(hue, 80 - n, n);
clouds.pixels[x + clouds.width*y] = c;
image(clouds, 0, 0, width, height);

I soon worked out I could change the speed that the cloud shapes moved by simply editing the float z and float dz lines

I also discovered that if I changed the colorMode from HSB (Hue, Saturation, Brightness) to RGB (Red, Green Blue) I got a very different effect.

One thing I noticed as I played with different settings in the sketch and tried them out, was how bright the LEDs were — they would definitely need some kind of diffuser. I tried some different frosted acrylic offcuts to see which I preferred and also varied the distance of the diffuser from the lights to vary the amount of diffusion.

These physical alterations coupled with the alterations in the sketch give quite a variety of effects from a very simple set up.

I’ve made a simple enclosure to house NeoPixel Matrix and the FadeCandy that allows me to easily change the colour of the diffuser.

Here's how it looks


I thoroughly enjoyed this project and have produced some nice lighting effects. The most exciting thing, however, is that I feel I’ve just scratched the surface and there is an awful lot more I can do. There is the possibility of making the lights interactive using sound or visual input and the display can be expanded as NeoPixels matrices can be chained together and a single FadeCandy can control up to 8.

I currently look after production at AB Open. I have a background in the arts, environmental conservation and IT support. In my spare time I do a bit of DJing and I like making things.

11 Dec 2018, 15:33