Arduino RGB LED Control Code with Excel

Map out pixels and auto-generate Arduino code for RGB matrix using Excel.

Jeremy Cook
5 years agoLights

WS2812 RGB LEDs have revolutionized what people are able to make with Arduino boards on a rather limited budget, but when you need to program them in a grid, things get a bit more complicated. As Kevin Darrah shows us in the video below, an X/Y matrix will generally loop through pixel numbers in a “snaking” pattern, which simplifies wiring, but makes programming lights on the grid a bit difficult as well.

X/Y LED selection, however, is a bit easier for Darrah. He’s developed a clever tool that lets him visually input the pixels that he wants to turn on in a 16x16 cell arrangement in Excel. This then generates a — potentially extremely long — cell with the text ‘mapLEDXY(X,Y,R,G,B);’ included over and over for each LED that needs to be lit up. Each mapLEDXY text segment dictates the X/Y position by the first two numbers, and the RGB values by the last three.

While you could hack out the same thing by counting your rows and columns, it’s not hard to see how this would be extremely helpful, especially when working with LED animations. RGB values here can even be output as variables, so if you want your lights to fade in and out in a program in a particular pattern, this is also very doable. The Arduino of course needs to know how to handle ‘mapLEDXY(X,Y,R,G,B), which Darrah explains in the first part of the video. Arduino code and the Excel file are available in the video description if you’d like to examine this technique further!

Jeremy Cook
Engineer, maker of random contraptions, love learning about tech. Write for various publications, including Hackster!
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles