Building the (LED) Matrix


So at work we have one of those SOC World Clocks that looks a little bit like the one below (and yes I know that London is not spelled with that many “o” letters…I found this on the Internet.). It works OK but has to be reprogrammed for daylight savings time, it loses time and, well, it is kind of single purpose. It is 2015 and I thought that we should have something more flexible, more functional and really I have always wanted to play with LED matrices. So my goal was, at the very least, to replace this old wall relic with something from this century.

Pic from


I looked at several places and finally settled on buying the equipment needed for this project at Adafruit. Their tutorials and videos are very helpful and I had high hopes that their gear would just work. It did! Below is what I chose for my project. You can definitely alter it for yours.

I bought it all for about $200 (minus the Pi) and did the soldering (see below). I cabled everything up and it just worked. Ahhhhhh. A great feeling.


First thing I sourced was the appropriate LED matrix. I knew I wanted something that could hang on the wall and could be seen across a 10-20 meter room. I also wanted something that had the LEDs in close formation (pitch) so that the content displayed on the matrix looked sharp. The Adafruit 64×32 LED Matrix, 4mm looked to be just what I wanted AND it could be chained to other 64×32 matrices to make a longer display. I bought 2 of these at roughly $80 each.

Adafruit 64x32 RGB LED Matrix - 4mm pitch
Adafruit 64×32 RGB LED Matrix – 4mm pitch


The next piece was to get something to interface with my Raspi2. Adafruit has that covered too with their Adafruit RGB Matrix HAT + RTC for Raspberry Pi – Mini Kit. At $25 it is well worth it for someone like me that is more interested in using the LED matrix than figuring pin-outs and such.

WARNING: You will need to do some simple soldering with this kit. So if you don’t have that equipment or those skills, beware.

The benefit of the HAT is that I don’t have to connect every single pin to every other one. There are easy cables to plug in that “just work”. So you do the soldering (instructions are here) and then cable everything up with the included cables.

Adafruit RGB Matrix HAT + RTC for Raspberry Pi - Mini Kit
Adafruit RGB Matrix HAT + RTC for Raspberry Pi – Mini Kit


The Pi is not able to run the LED matrices without an external power supply. Knowing I wanted to run a couple of matrices off of the HAT, I chose a 10A (a little overkill) 5v power supply for about $25. I found out later that this power supply will actually power 2 64×32 LED matrices, the HAT AND my Pi.


Current State

My goal was to be able to display streaming/moving text on the matrices. Adafruit got me started with their AMAZING documentation. Step 6 in the “Driving the Matrices” section describes the python and other software you need to download/install in order to get your matrices up and running. I followed the directions and it just worked (sensing a trend here?).

I took the demo python code from the download (in the previous steps this was downloaded and compiled) and started tinkering. The demos show how to move content on the matrices and also how to draw, display images and they hint at writing text.

My code (available on my GitHub site is the result of my lessons learned. It:

  • Has a function to move text left to right or right to left
  • Has a function to move text up or down
  • Generates an “image” from text you choose and then displays that on the display
  • Has a “world clock” function in it to generate the time in different time zones

[UPDATE] October 2015

I’ve added several features to the code. One pulls the local food truck data from a site on the Internet and displays it on the panel. The other interfaces with the API at Washington DC area Metro Train web site and pulls the time to next train for a certain station. Check out the YouTube video below to see it in action.

What does it look like?

HAT on the Raspi2
Matrix display magnetically mounted and cabled up.

And a video of it working:

14 thoughts on “Building the (LED) Matrix

  1. I’m designing a dashboard for an electric motorcycle I’ve built. How does the display fair outside in direct sunlight?

    1. The display is quite bright but I have not taken it outside to look. In daylight (from windows) it is sufficiently bright to read.

      1. In bright, direct sunlight… It looks horrible, lol. I’ll have to figure out a polarizing filter and a hooded enclosure. Or just scrap it & try a different method.

      2. Aw. Really sorry that it didn’t work out. Let me know what you end up doing and post some pics to show your final product!

  2. Hello WebBreacher!

    Can You send me changes in file to fit your code for 64×32 adafruit panel?
    I can’t run it 🙁

    Result: 0xCF33070 v 0xCF33070
    Traceback (most recent call last):
    File “”, line 196, in
    image = CreateImage(‘-> NoVA Hackers <-', 124, 124, (180, 0, 0))
    File "", line 103, in CreateImage
    if textImage.getpixel((bx, by)) == 0: # text background
    IndexError: image index out of range


    1. Hi Jack.

      All the code in this script is set for image height of 32 LEDs/pixels. So you are good there.

      If you look at the code, line 70 has the default width set to 2200 for text and image. Try reducing those to about 1100. Also, at the bottom, each time the CreateImage() function is called, it passes the width of the text and image to the function. It is the first 2 numeric params. Try changing those.

      Can you get the matrix to display any of the content? Perhaps the first “MatrixFill(0x00AA00, 1) #Fill the matrix with a single color” could be uncommented and tried to see if the script sends anything to the matrix.

      Finally, do you have all the prereq software to drive the matrix downloaded and local to the script?

      1. Thank you very much for your answer! Already yesterday I checked, the panel fills the pattern (the first line of MatrixFill). This function works ok. Unfortunately, after the changes proposed by you is the same error.

        I just need a simple program that displays on the panel text read from the file. I want to make the panel for temperature sensors, pressure, humidity, etc. Your program seems to good to change it for my purposes

        With all of this I can handle, but with the panel rgb I contact two days and I’m not a programmer. Maybe You have any simple python or php program to send text to panel? I have raspberry pi and adafruit rgb hat.

        best regards

      2. Hello!

        I started the panel with another script and it works Ok, I changed it only for my needs.

        I like your script but now I have no free time. Maybe someday I will return to him and preferable to try to run.

  3. Hello,
    I followed (I think!) your instructions above, but made an adjustment for a 32 x 32 display. Line 70 has had the two 2200 parameters set to 550, yet I still get the error pointed out by Jack. The MatrixFill line, when it’s the only routine called, works just fine, giving me a green display. Can you explain the significance of the parameters passed to the CreatImage() function and how different values affect the display?

    I should mention that I have plenty of programming experience, but none if it with Python, so I’m on a bit of a learning curve!


    1. Thanks for the comments Jack and Michael. I need to look into this with my panel (which has been off for a while) next week and see if I can troubleshoot more. It may be that the code from Adafruit has changed and so I need to change my code to match. I will look into this.

      You may also want to see if the panel works with Just to get content flowing across the screen(s). I will look into this gents.

      Michael…the 2200 was a number/param I passed to the function for the image’s width. Since the matrices only display images, I created text, then transform it into an image and then display it. For long text, giving it a width longer than the number of LEDs in the width of your panel allows a kind of buffering. So picture yourself looking straight ahead and someone moving a long picture from left to right across your vision. That is what is happening in this script. The LEDs stay constant and we “drag” a picture across the screen to show it.

Comments are closed.

Up ↑

%d bloggers like this: