32×32 RGB LED Matrix On The Raspberry Pi


At the last Cambridge Jam I picked up a 32×32 LED matrix panel from SK Pang. This consists of 1024 RGB leds and is used as a building block for those large displays you see in stadiums. I could only afford one so my screen is slightly smaller.

It consists of the panel, a ribbon cable, a GPIO adapter and a power cable. I used a RAVPower 10400mAh USB power bank to power it. You need a power source that can provide 5V with at least 2A.

Driving the screen requires a lot of data to be sent to the screen on a constant basis. This makes it unsuitable for Python but better suited to C. I tend to use Python so this makes it slightly outside my comfort zone. Lucky for me Henner Zeller has created a library of C code to drive this board via the Raspberry Pi’s GPIO pins and made it available on his rpi-rgb-led-matrix Github page.

Install C Library

You can download the code to your Pi using :

wget https://github.com/hzeller/rpi-rgb-led-matrix/archive/master.zip

and then unzip the archive using :

unzip master.zip

Once extracted you can change to the subdirectory :

cd rpi-rgb-led-matrix-master/

and then compile the code using :



Once compiled you can run the resulting executable using :


which will display the available command line options :

usage: ./led-matrix <options> -D <demo-nr> [optional parameter]Options:
 -r <rows> : Display rows. 16 for 16x32, 32 for 32x32. Default: 32
 -c <chained> : Daisy-chained boards. Default: 1.
 -L : 'Large' display, composed out of 4 times 32x32
 -p <pwm-bits> : Bits used for PWM. Something between 1..7
 -g : Do gamma correction (experimental)
 -D <demo-nr> : Always needs to be set
 -d : run as daemon. Use this when starting in
      /etc/init.d, but also when running without
      terminal (e.g. cron).
 -t <seconds> : Run for these number of seconds, then exit.
         (if neither -d nor -t are supplied, waits for <RETURN>)
Demos, choosen with -D
 0 - some rotating square
 1 - forward scrolling an image (-m <scroll-ms>)
 2 - backward scrolling an image (-m <scroll-ms>)
 3 - test image: a square
 4 - Pulsing color
 ./led-matrix -t 10 -D 1 runtext.ppm
Scrolls the runtext for 10 seconds

To get something on the panel you can try the including example image “runtext.ppm” :

sudo ./led-matrix -d -t 20 -D 1 runtext.ppm

If your panel is connected correctly and has enough power the “runtext.ppm” image will be scrolled across the screen for 20 seconds.

Custom Graphics

Creating your own graphics to scroll is really easy as long as you have an image editing application that can create Portable Pixmap Format (PPM). I use the GIMP (it’s free!) and this file tpye is available via the “Export as” feature.

You start by loading or creating your source image and then re-sizing it so that it is only 32 pixels high. The width doesn’t matter as it is going to be scrolling horizontally. In GIMP you can simply use “Export as”, use a filename with a .ppm extension and select “Raw” when prompted. This file can then be copied to your Pi. My first custom graphic was a logo and some text :

Raspberry Pi Spy Strip

The command below scrolled this nicely across the panel :

sudo ./led-matrix -d -t 60 -D 1 rpi_logo.ppm

My next test was a small set of flags that looked something like this :

Flag Strip

Here is custom_ppm_images zip file with my custom PPM images if you want to try them.

The panel is great fun and the videos don’t really do it justice. As long as you can generate the PPM files you can scroll whatever you like.

I am going to start looking at the C code and see if I can modify it play back a sequence of images from a directory. That way I can create animations. It would also be good to use Python to generate a file and then trigger the C programme to display it.

GPIO Reference

For reference here are the connections between the panel and the Raspberry Pi’s GPIO header :

Panel Connections        Pi Header Connections
=================        =====================
GND (Ground, '-')        Ground
R1 (Red 1st bank)        GPIO17
G1 (Green 1st bank)      GPIO18
B1 (Blue 1st bank)       GPIO22
R2 (Red 2nd bank)        GPIO23
G2 (Green 2nd bank)      GPIO24
B2 (Blue 2nd bank)       GPIO25
A (Row address)          GPIO7
B (Row address)          GPIO8
C (Row address)          GPIO9
D (Row address)          GPIO10
OE- (neg. Output enable) GPIO 2 (Pi Rev 2)
                         GPIO 0 (Pi Rev 1)
CLK (Serial clock)       GPIO 3 (Pi Rev 2)
                         GPIO 1 (Pi Rev 1)
STR (Strobe row data)    GPIO 4


  1. Hi,

    nice work!
    I also got this Panel and i tried to run it with the Raspberry Pi, but with no success:o(.
    Only the first rows of the Panel are activated. My power supply to the panel has 5 V with 2 A. May you state your connections from the panel to the Raspberrry Pi, please:

    RO (Panel PIN) = ? (RPI PIN)
    G0 (Panel PIN) = ? (RPI PIN)
    B0 (Panel PIN) = ? (RPI PIN)
    GND (Panel PIN) = ? (RPI PIN)
    R1 (Panel PIN) = ? (RPI PIN)
    G1 (Panel PIN) = ? (RPI PIN)
    B1 (Panel PIN) = ? (RPI PIN)
    GND (Panel PIN) = ? (RPI PIN)
    A (Panel PIN) = ? (RPI PIN)
    B (Panel PIN) = ? (RPI PIN)
    C (Panel PIN) = ? (RPI PIN)
    D (Panel PIN) = ? (RPI PIN)
    CLK (Panel PIN) = ? (RPI PIN)
    STB (Panel PIN) = ? (RPI PIN)
    OE (Panel PIN) = ? (RPI PIN)
    GND (Panel PIN) = ? (RPI PIN)

    Thank you in advanced

    • The screen will display whatever the code can throw at it … but the library I’m using is designed around PPM files. It’s the code that converts the PPM to the required signals. Technically you could modify the C code to convert any input images.

      • I contacted the guy who created the code a while back, Hans Zeller, he got back to me the other day and said that the code now supports gifs and other file formats.

  2. I hooked up a panel and ran your awesome demo program, but my display is extremely “jiggly”… The pixels jump around left to right, causing the letters and images to look somewhat fuzzy/jaggy and irregular. Any ideas on what the problem could be? Bad panel? Noisy power supply? EMF? Any help would be extremely appreciated. PS – thanks for doing the library for these panels!

    • Hi John,

      Any luck with your issue. I seem to be having a similar issue. Seems quite irregular. I agree, seems very noisy. About to go over the wiring again to see if anything is amiss… weird

    • It may be the power supply. I had some flickering with my panel when I used a power supply that couldn’t quite supply the correct current and voltage under load.

  3. Hello,
    I wonder if it is possible that, instead of images, the matrices displayed text.
    I know that a text to image conversion is possible, but I was thinking displaying text from a keyboard input (a real time interaction).
    Does anybody have an idea on how to go about it?
    I’m a beginner and any guidance is greatly accepted 🙂

    • The only way to do it would be to collect keypresses to build a string of text, convert to an image and overwrite the image being sent to the panel. I seem to think you can replace the image and the panel will use the modified image.

      • And would that be achieved through C code? If you could point me to some sort of example on how to go about this I would appreciate it!

        • You could create it in any language but it should be possible to do it in C or Python. It could run independently of the screen driver. It just needs to collect keypresses, build a string and then update the image file that the screen driver was using to send to the panel. I’ve got no examples so it would be a case of building up the functionality a step at a time.

  4. Good day,

    I am very interested in Arduino and led rgb`s. My first thought was however how one would display full color dvd like video?

  5. Hi,
    great tutorial, just wondering is there an easy way to scroll text across the LED panel rather than using image files?



  6. Hi
    I am trying to move single led pixel with keyboard arrow keys with different libraries but it did not get sucess in adafruit rgb-led-panel 32×32 matrix, please give me some suggestion for this application.

  7. Hi
    I ran the make but nothing happens. It doesn’t
    give any error message just does not create the led-matrix file

    Any ideas

Leave A Reply