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 :
and then unzip the archive using :
Once extracted you can change to the subdirectory :
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 Example: ./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.
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 :
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 :
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.
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