We have example code ready to go for these displays. It does not work with every board out there. See the “Compatible Hardware” lists on the opening page for guidance.

The library works with a LIMITED NUMBER of boards, including the Arduino Uno and Arduino Mega. The Arduino Leonardo, despite its shape, is NOT supported due to its peculiar pinout.
For 32-bit microcontrollers such as SAMD21 (“M0”), SAMD51 (“M4”), RP2040 and ESP32, please use the Adafruit_Protomatter library instead, which can be installed using the Arduino Library Manager.

Support for 32-bit microcontrollers — M4, RP2040, ESP32, etc. — is documented in a different library called Protomatter, documented here.

Arduino Uno support is limited to the 32x16 matrix, and only “single-buffered” (i.e. no smooth animation), despite any comments in the examples that might suggest otherwise.

Over time, RAM required by the core Arduino code and the matrix-driving graphics libraries has increased…a few bytes here and there as bugs are fixed and features are added. Early on, 32x32 (or double-buffered 32x16) just barely fit in the Arduino Uno’s RAM, with a few dozen bytes to spare for user code. This is no longer the case. But you might still see references to this in older code.

Some libraries need to be downloaded and installed: first is the RGB Matrix Panel library (this contains the low-level code specific to this device), then the Adafruit GFX Library (which handles graphics operations common to many displays we carry) and Adafruit BusIO.

Both libraries can be found and installed using the Arduino Library Manager (Sketch→Include Library→Manage Libraries…). Search for “gfx” and “rgb matrix panel” and install the corresponding Adafruit libraries.

Now you are ready to test! Open up the IDE and load File→Examples→RGBmatrixPanel→testcolors_16x32 (for the 16x32 panel) or File→Examples→RGBmatrixPanel→colorwheel_32x32 (for the 32x32 panel). There’s also a testshapes_32x64 example for boards with sufficient RAM.

If using an Arduino Mega 2560, in addition to wiring changes previously mentioned, you'll need to make a small change to each of the example sketches. This line:

#define CLK 8  // MUST be on PORTB! (Use pin 11 on Mega)
Should be changed to:
#define CLK 11

(Any of digital pins 10-13 and 50-53 can be used for this function on the Mega, with the corresponding wiring change. The examples all reference pin 11.)

If using an Adafruit Metro M4 (not M0 or 328), the CLK change would instead be:

#define CLK A4
After uploading, with the 16x32 panel you should see the following:
This is a test pattern that shows 512 colors (out of 4096) on the 512 pixels. Since there's no really elegant way to show a 3-dimensional color space (R/G/B) in two dimensions, there's just repeating grids of red/green with increasing blue. Anyways, this shows you the range of colors you can achieve!

or, with the 32x32 panel:
Now that you've got it working here are a few things to look for:

The most useful line to look at is:
      matrix.drawPixel(x, y, matrix.Color333(r, g, b));
which is where we actually draw to the display. This code only draws one pixel at a time. The x and y coordinates are the individual pixels of the display. (0,0) is in the top left corner, (31, 15) is in the bottom right (remember that we start counting at 0 here!). To create a color, you will want to use the helper funciton Color333 which will take three 3-bit numbers and combine them into a single packed integer. So for example, the first argument, r can range from 0 to 7. Likewise for gand b. To make a pixel that is pure red, r would be 7 and g, b would be 0. To make a white pixel, set all to 7. To make a black (off) pixel, set the colors to 0. A similar function, Color444, accepts three 4-bit numbers for up to 4096 colors.

Now we can open up the next example, which shows the rest of the library capabilities.

This guide was first published on Dec 11, 2012. It was last updated on Mar 08, 2024.

This page (Test Example Code) was last updated on Mar 08, 2024.

Text editor powered by tinymce.