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. 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.
Plugged into a socket on the LED matrix, one header now faces away from you. If you double the cable back on itself (not a twist, but a fold)…to access a specific pin on the socket, the left and right columns are now mirrored (rows are in the same order — the red stripe provides a point of reference). You’re looking “up” into the plug rather than “down” into the socket.
For example, R1 (the top-left pin on the INPUT socket) appears at the top-right of the exposed plug. You can jam a wire jumper in that hole to a corresponding pin on the Arduino…
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.
With the free end of the ribbon off the side, it’s easier to see both the front of the matrix and the Arduino simultaneously, for making additional connections or for troubleshooting.
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:
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, connect these to digital pins 2, 3 and 4.
On Arduino Mega, connect to pins 24, 25 and 26.
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, that’s pins 5, 6 and 7.
On Arduino Mega, pins 27, 28 and 29.
For 32x32 and 64x32 matrices, LAT connects to Arduino pin 10.
For a 32x16 matrix, use Arduino pin A3.
This is the same for Arduino Uno or Mega.
The LAT (latch) signal marks the end of a row of data.
CLK connects to pin 8 on an Arduino Uno, or pin 11 on an Arduino Mega.
The CLK (clock) signal marks the arrival of each bit of data.
OE connects to Arduino pin 9. This is the same for both the Arduino Uno and Mega.
OE (output enable) switches the LEDs off when transitioning from one row to the next.
That’s it. You can skip ahead to the “Test Example Code” page now.