Individually-addressable RGB (and RGBW) LEDs like NeoPixels and generic WS2812Bs have made it easier than ever before to add colorful lighting effects to just about any project. If your project calls for a linear or grid pattern, then controlling those LEDs is very straightforward. But it becomes significantly more complicated if your LEDs are arranged in an unusual pattern or across an irregular surface. Without the ability to use simple coordinates, how do you target the specific LEDs you want? It turns out that it isn’t too difficult, and Scott Marley has a great video explaining how to accomplish that.
To demonstrate how this works, Marley laid a bunch of typical WS2812B LEDs on the surface of a face mask. Those are wired with the signal in a serpentine pattern and are controlled by an Arduino Nano board with the popular FastLED Arduino library. This represents a common hardware setup and also makes the challenge obvious. The mask has curved organic surfaces, the LEDs are not arranged in a basic grid, and there are gaps in the LEDs for the eyes. You’d have a really hard time adapting animation effects to this LED layout without the help of some additional software.
Fortunately for all of us, software does exist to help. Garret Mace created the fantastic FastLED XY Map Generator, which is conveniently available online. All you have to do is use the tools on that website to create a representation of the rough layout of your LEDs and set some information about how they’re wired. The web app will then output a table that contains that information. Once you put that table in your Arduino code, you can use any of the many effects libraries out there that are intended for conventional LED grids. As far as the effects code is concerned, you are using a grid. But the table you generated maps that grid across a layout that much more closely resembles what you have actually built so the animation effects aren’t distorted.