32x16 and 32x32 RGB LED Matrix Created by Phillip Burgess Last updated on 2019-04-23 05:37:20 PM UTC
Overview This guide is for ARDUINO and compatible boards — Arduino Uno, Mega, Zero, and Adafruit Metro 328, Metro M0 and M4. We have a different guide for Raspberry Pi (https://adafru.it/kdh). Bring a little bit of Times Square into your home with our RGB LED matrix panels. These panels are normally used to make video walls — here in New York we see them on the sides of buses and on bus stops — to display animations or short video clips.
These panels require 12 or 13 digital pins (6 bit data, 6 or 7 bit control) and a good 5V power supply, at least a couple amps per panel. We suggest our 2A (or larger) regulated 5V adapters and either a terminal block DC jack, or solder a jack from our DC extension cord. Please read the rest of our tutorial for more details! Keep in mind that these displays are normally designed to be driven by FPGAs or other high speed processors; they do not have built in PWM control of any kind.
Power Although LEDs are very efficient light sources, get enough of them in one place and the current really adds up. A single 32x16 or 32x32 RGB matrix, running full tilt (all pixels set white), can require nearly 4 Amps of current! Double that figure for a 64x32 matrix. On average though, displaying typical graphics and animation, these panels will use less…a 2A supply is usually sufficient for a single 32x16 or 32x32 panel, or 4A for a 64x32 panel.
Solder both pins correctly to the power port. Make sure you get this right because there is no protection diode! If your panel has the Molex-style header, just plug in the included power cable, observing the correct polarity. © Adafruit Industries https://learn.adafruit.
If your power cable came with spades at the opposite end of this power cable, they can be screwed into a 2.1mm terminal block adapter. Works nicely! Don't allow the exposed connectors to contact metal though…you should probably cover this with heat-shrink tube or electrical tape. You may receive power cables with different endings, e.g. round instead of spade ends, or maybe with another Molex connector. Just strip the cables and wire directly to the power plug © Adafruit Industries https://learn.
© Adafruit Industries https://learn.adafruit.
Connections These panels are normally designed for chaining (linking end-to-end into larger displays)…the output of one panel connects to the input of the next, down the line. With the limited RAM in an Arduino, chaining is seldom practical. Still, it’s necessary to distinguish the input and output connections on the panel…it won’t respond if we’re connected to the wrong socket. Although the panels support chaining, this is VERY impractical on Arduino-class boards and our library DOES NOT SUPPORT it.
A 32x16 panel uses this pin arrangement. The labels might be slightly different, or the pins might not be labeled at all…but in either case, use this image for reference. Notice there are four ground connections. To ensure reliable performance, all four should be connected to GND on the Arduino! A solderless breadboard is handy for making this split. Here’s the layout for 32x32 and 64x32 panels. We’ll call this “Variant A.” Some panels use different labels, but the functions are identical.
“Variant B” for 32x32 and 64x32 panels. The wiring is identical to Variant A above, only the labels are different. Ground pins aren’t labeled, but still need to be connected. LAT (latch) is labeled STB (strobe) here. R1/G1/B1/R2/G2/B2 are changed to R0/G0/B0/R1/G1/B1… but again, no functional difference, it’s just ink. Our earliest 32x32 panels had a two-socket design, let’s call it “Variant C.” All the same pin functions are present but the layout is very different.
few control lines can be reconfigured, but others are very specific…you can’t wire the whole thing willy-nilly. The next pages demonstrate compatible wiring…one using the RGB Matrix Shield, the using jumper wires. © Adafruit Industries https://learn.adafruit.
Connecting Using RGB Matrix Shield This is the preferred method for pairing these matrices with an Arduino-sized board, as it’s quick and trouble-free. The Adafruit RGB Matrix Shield works with the Arduino Uno and compatible ATmega328-based boards like the Adafruit Metro. It also works directly with the Adafruit Metro M0…and with one or more jumper wires can work with the Metro M4 (and potentially other boards with this form factor, if a compatible Arduino library is available).
The shield requires a small modification to work with the Adafruit Metro M4: Use a small file or hobby knife to cut the PCB trace between the two pads indicated here. Solder a wire from the adjacent “CLK” pin to the “Analog In 4” pin. A corresponding change is required in one’s code — look for the “CLK” pin definition in any of the matrix examples… #define CLK 8 And change the “8” to “A4”: #define CLK A4 © Adafruit Industries https://learn.adafruit.
Connecting with Jumper Wires Ribbon cables and their corresponding headers are sometimes a topological puzzle. Here’s a trick to help keep track… If you hold the ribbon cable flat — no folds — and with both connectors facing you, keys pointed the same direction — now there is a 1:1 correlation between the pins. The top-right pin on one plug links to the top-right on the other plug, and so forth. This holds true even if the cable has a doubled-over strain relief.
So! From the prior page, refer to the socket that’s correct for your matrix type. The labels may be a little different (or none at all), but most are pretty close to what’s shown here. Then swap the columns to find the correct position for a given signal. Either end of the ribbon cable can be plugged into the matrix INPUT socket. Notice below, the “key” faces the same way regardless. With the free end of the ribbon toward the center of the matrix, the Arduino can be hidden behind it.
Using color-coded wires helps a lot! If you don’t have colored wires, that’s okay, just pay close attention where everything goes. Our goal is a fully-populated plug like this: So! Let’s proceed with the wiring, in groups… Connect Ground Wires 32x32 and 64x32 matrices require three ground connections. 32x16 matrices have four. Current Arduino Uno and similar boards have three ground pins (the third is next to pin 13).
Upper RGB Data © Adafruit Industries https://learn.adafruit.
Pins R1, G1 and B1 (labeled R0, B0 and G0 on some matrices) deliver data to the top half of the display. On the Arduino Uno and Adafruit Metro (328, M0 or M4) boards, connect these to digital pins 2, 3 and 4. On Arduino Mega, connect to pins 24, 25 and 26. Lower RGB Data © Adafruit Industries https://learn.adafruit.
Pins R2, G2 and B2 (labeled R1, G1 and B1 on some matrices) deliver data to the bottom half of the display. These connect to the next three Arduino pins… On Arduino Uno and Adafruit Metros, that’s pins 5, 6 and 7. On Arduino Mega, pins 27, 28 and 29. Row Select Lines © Adafruit Industries https://learn.adafruit.
Pins A, B, C and D select which two rows of the display are currently lit. (32x16 matrices don’t have a “D” pin — it’s connected to ground instead.) These connect to pins A0, A1, A2 and (if D pin present) A3. This is the same for all boards. LAT Wire © Adafruit Industries https://learn.adafruit.
The LAT signal connects to Arduino pin 10. This is the same for all boards. The LAT (latch) signal marks the end of a row of data. OE Wire © Adafruit Industries https://learn.adafruit.
OE connects to Arduino pin 9. This is the same for all boards. OE (output enable) switches the LEDs off when transitioning from one row to the next. CLK Wire Last one! CLK connects to… Pin 8 on Arduino Uno, Adafruit Metro 328 or Metro M0. Pin 11 on Arduino Mega. Pin A4 on Adafruit Metro M4 (not shown, but you get the idea). The CLK (clock) signal marks the arrival of each bit of data. © Adafruit Industries https://learn.adafruit.
That’s it. You can skip ahead to the “Test Example Code” page now. © Adafruit Industries https://learn.adafruit.
Connecting Using a Proto Shield As mentioned on the “Jumper” page: if you hold a ribbon cable flat — no folds — and with both connectors facing you, keys pointed the same direction — there’s is a 1:1 correlation between the pins. The top-right pin on one plug links to the top-right on the other plug, and so forth. This holds true even if the cable has a doubled-over strain relief. As long as the keys point the same way and the plugs face the same way, pins are in the same positions at both ends.
Wires are then soldered from the header to specific Arduino pins on the proto shield. Try to keep wire lengths reasonably short to avoid signal interference. Using color-coded wires helps a lot! If you don’t have colored wires, that’s okay, just pay close attention where everything goes. Our goal is a proto shield something like this: It’s not necessary to install all the buttons and lights on the proto shield if you don’t want — just the basic header pins are sufficient.
Depending on the make and model of proto shield, some pins are designed to connect in short rows. Others don’t. For the latter, strip a little extra insulation and bend the wire to wrap around the leg of the socket from behind, then solder. Connect Ground Wires 32x32 and 64x32 matrices require three ground connections. 32x16 matrices have four. Most proto shields have tons of grounding points, so you shouldn’t have trouble finding places to connect these.
Pins R1, G1 and B1 (labeled R0, B0 and G0 on some matrices) deliver data to the top half of the display. On the Arduino Uno and Adafruit Metro (328, M0 or M4) boards, connect these to digital pins 2, 3 and 4. On Arduino Mega, connect to pins 24, 25 and 26. Lower RGB Data Pins R2, G2 and B2 (labeled R1, G1 and B1 on some matrices) deliver data to the bottom half of the display. These connect to the next three Arduino pins… On Arduino Uno and Adafruit Metros, that’s pins 5, 6 and 7.
Pins A, B, C and D select which two rows of the display are currently lit. (32x16 matrices don’t have a “D” pin — it’s connected to ground instead.) These connect to pins A0, A1, A2 and (if D pin present) A3. This is the same for both the Arduino Uno and Mega. LAT Wire For 32x32 and 64x32 matrices, LAT connects to Arduino pin 10. This is the same for all boards. The LAT (latch) signal marks the end of a row of data. OE Wire © Adafruit Industries https://learn.adafruit.
OE connects to Arduino pin 9. This is the same for all boards. OE (output enable) switches the LEDs off when transitioning from one row to the next. CLK Wire Last one! CLK connects to… Pin 8 on Arduino Uno, Adafruit Metro 328 or Metro M0. Pin A4 on Adafruit Metro M4. Pin 11 on Arduino Mega. The CLK (clock) signal marks the arrival of each bit of data. Here’s that photo again of a completed shield.
© Adafruit Industries https://learn.adafruit.
Test Example Code We have example code ready to go for these displays. It's compatible with the Arduino Uno or Mega…but not other boards like the Leonardo, nor “Arduino-like” boards such as Netduino…programming gurus might be able to port it to other microcontrollers by adapting the C++ source, but as written it does some pretty low-level, non-portable things. The library works with a LIMITED NUMBER of boards: Arduino Uno, Mega, Zero, Adafruit Metro M0 and Metro M4.
#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.
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!).
Library Next up, load the testshapes_16x32 or testshapes_32x32 example sketch, which will test every drawing element available (again, you may need to edit the pin numbers for the 32x32 panel). The most simple thing you may want to do is draw a single pixel, we saw this introduced above. // draw a pixel in solid white matrix.drawPixel(0, 0, matrix.Color333(7, 7, 7)); Next we will fill the screen with green by drawing a really large rectangle.
// draw a blue circle matrix.drawCircle(7, 7, 7, matrix.Color333(0, 0, 7)); // fill a violet circle matrix.fillCircle(23, 7, 7, matrix.Color333(7, 0, 7)); fillScreen allows you to fill the entire screen with a single color: // fill the screen with 'black' matrix.fillScreen(matrix.Color333(0, 0, 0)); Finally, we draw the text that is shown up top as the demonstration image. We can use the print function, which you'll be familiar with from Serial. You can use print to print strings, numbers, variables, etc.
© Adafruit Industries https://learn.adafruit.
How the Matrix Works There's zero documention out there on how these matrices work, and no public datasheets or spec sheets so we are going to try to document how they work. First thing to notice is that there are 512 RGB LEDs in a 16x32 matrix. Like pretty much every matrix out there, you can't drive all 512 at once. One reason is that would require a lot of current, another reason is that it would be really expensive to have so many pins. Instead, the matrix is divided into 8 interleaved sections/strips.
Image above by rhb.me (CC By-NC-SA) “Notice that the LED panel current consumption decreases as clock frequency increases. This suggests that the LED ‘on time’ is decreasing. I’m guessing this is caused by frequency-invariant delays in the LED driver shift registers.” © Adafruit Industries https://learn.adafruit.
FAQ I'm seeing weird pixel artifacts, ghosting, or other glitches. © Adafruit Industries https://learn.adafruit.
Wiring Issue Examples Wiring issues tend to look like this and are often fixable if you can find the wrong / bad wire. © Adafruit Industries https://learn.adafruit.
Ghosting Issue Examples You see what you expect for the most part, but also some other artifacts. This can happen even with proper wiring. © Adafruit Industries https://learn.adafruit.
© Adafruit Industries https://learn.adafruit.
Downloads Files Fritzing object in the Adafruit Fritzing Library (https://adafru.it/aP3) EagleCAD PCB Files in GitHub (https://adafru.