Custom NeoPixel LED panel with unicorn library (RPi 3)


Hi guys!

I soldered my own LED panel consisting of 4 horizontal stripes that contain 24 WS2811 LEDs each - so it’s 24x4. It’s just a test, later it will be 24x12. It’s working fine - with one restriction: I cannot feed my own content to it. I’m just lacking the coding skills. So I just tried out the unicorn library - with (limited) success! It comes with plenty of examples and of course a big community of tinkerers. The limitiation of the success lies - as you might guess - in the different layout of the panel. the unicorn library is written for 8x8 panels! So the display on my panel is A) fractured and B) not all LEDs are used.

So pleeeease, I SOOOO want my beautiful LED panel to do tons of funny stuff. Can someone take me by the hand and change some of the code to fit my panel?

I’m actually sure that I’m not the only one that would gain something from it. I mean… soldering a panel from a long LED strip, connecting three wires to the Pi, run a script - super easy. AND SUPER FUN! :)


Have a look see here,


Thanks, alphanumeric! Most of the posts and articles you linked to I have already read several times. I did not find a straight answer to my questions there. For me it needs to be a bit more detailed, since I’m new to python.


You shouldn’t use Unicorn HAT, but rather

This is the library that underpins Unicorn HAT and communicates with the LEDs.

You can see pretty much everything you’ll need to know about using it right at the top of Unicorn HAT’s library code:

And then you call ws2812.setPixelColorRGB(x, r, g, b) where x is the index of the pixel you want to set and r, g, b is the colour.

Do you have a layout diagram for your panel, showing the relationship between pixel order and X/Y position?

In order to create a setPixel that understands x, y coordinates you need to come up with some way of realising your mapping in Python. Unicorn HAT is pretty crude in this respect, just storing all the pixel indexes in a two dimensional array and looking them up like index = mapping_table[x][y]


The only thing close to what you have, that I have, is my Micro Pixel Edge for my BBC Micro Bit. It’s just one row of 10 LEDS. I programed it in Micro Python. I had a really hard time finding said info for it. I don’t think my code will help you much. I went by this,


Thanks for the tip to use that library!
I installed by running:

git clone

What else do I have to do to use it?
The thing is, in a frenzy I installed several different libraries and I’m not sure when which one is being used.

Let me elaborate…
pi@raspberrypi:~ $ sudo ./rpi_ws281x/test -sgbr -x24 -y4 -g18 -c
Runs awesome! It generates a scrolling rainbow over the whole panel

After the latest
git clone https//
I got these new folders: ~/rpi_ws281x-python/library/rpi_ws281x
What should I do with them?


Sorry, I forgot to answer your question!
Yes, using a Christmas project from Andrew Oakley
I was able to include my layout:

# Size of your matrix

# LED matrix layout
# A list converting LED string number to physical grid layout
# Start with top right and continue right then down
# For example, my string starts bottom right and has horizontal batons
# which loop on alternate rows.
# Mine ends at the top right here:     -----------\
# My last LED is number 95                        |
#                                      /----------/
#                                      |
#                                      \----------\
# The first LED is number 0                       |
# Mine starts at the bottom left here: -----------/ 

           0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]


If you’ve installed Unicorn HAT you’ll probably already have rpi_ws281x and should be able to skip to starting to hack on the Unicorn HAT library code to make your own interface.


Yes, you’re right - it’s just the “hacking” part where I’m stuck :).
So if anyone can help me with that… tons of gold are waiting for you! MOUNTAINS!!


You could probably just paste your layout into and make a couple of tweaks to disable unsupported rotations, like this:

If you grab that file and save as you can then import mydisplay and use it as if it were a weirdly-shaped Unicorn HAT.