Intro: How to Make an Individually Addressable LED Matrix Sign
A few days ago, Adafruit posted a blog about their new NeoMatrix library.
They don't have any tutorials up, but linked to their github for anyone who just can't wait can go ahead and have a hack at it. So last night I pulled their code, soldered together some 60-LED density individually addressable strips that I had lying around, and had a working LED matrix in no time.
Step 1: Solder Together Some LED Strips Into a Matrix
When you download the code from github, you'll see a folder called "examples". Make sure the "examples" folder is in your "Arduino" folder, and is next to the "libraries" folder--NOT inside of "libraries"! If your folders are not in the right place, it will not work.
Next, download these libraries:
and put all of these folders inside of your "libraries" folder. Check the image of my folder structure to make sure yours is similar.
Now it's time to set up your LEDs. The NeoMatrix library gives you several options
for setting up your LED matrix. As you solder your LED strips together, make sure to keep in mind that you'll have to match up the physical configuration of your LEDs and adruino with what you've configured in your code.
Open "examples", and find "matrixtest". Open this file in your arduino IDE.
Near the top of the file, you'll find the line of code that is used to define your matrix object. Here's what mine looks like:
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(5, 7, 3,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
NEO_RGB + NEO_KHZ800);
Here's what that code means:
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix( = "build me a new matrix"
5 = "that is 5 pixels wide"
7 = "and 7 LED strips tall."
3 = "I will plug my blue data wire from my LED strips into pin 3 on my arduino."
NEO_MATRIX_TOP + NEO_MATRIX_LEFT = "The beginning of my strip, nearest the arduino, is at the top left corner of my matrix."
NEO_MATRIX_ROWS = "I'm orienting my strips horizontally, not vertically."
NEO_MATRIX_ZIGZAG = "I'm soldering my strips in a zigzag pattern, not a progressive pattern."
NEO_RGB = "My strips have RGB LEDs, not GRB LEDs."
NEO_KHZ800 = "My strips work at 800KHz." (These last two will be on the data sheet for the LED strips you bought.)
Take a look at the picture of my LEDs, and note:
- I have 5 LEDs per strip on 7 strips
- My arduino is in the top left corner of the matrix
- My blue data wire is soldered to pin 3 on my arduino
- My LED strips are horizontal
- I soldered them together in a "zigzag" pattern, meaning every other strip is upside-down (more on this next)
Step 2: Zigzag Vs. Progressive. What Does This Mean?
From our matrix object we just built, we were given many options. Luckily, most of them were very straight-forward. The step to choose "zigzag" or "progressive" may not have been so clear. Here's the difference:
A "progressive" arrangement of LEDs is soldered continuously. You snip the LED strip in two pieces, and solder wires directly between the two pieces. If you want to turn these into a matrix, you'll need to twist the second piece of strip around, so the wires will end up behind the LEDs. See the pictures for examples.
Step 3: ZigZag
I like to use zigzag in many cases. The LEDs lie flat, which is nice.
Zigzag is done by cutting your LED strip into pieces, turning every other strip upside down, and soldering them together on the sides. See the pictures for examples.
Step 4: Attaching to the Arduino
Now that you have your LEDs soldered together, you need to attach them to an arduino if you haven't already.
Remember, if you specified "3" in your matrix object in your code, you will need to attach your LED strip to pin 3 on your arduino.
Most LED strips have 4 wires: 2 black ground wires, 1 red power, and 1 blue data/signal wire. We only need 1 black, 1 red, and 1 blue in this case. (There are two black wires for other cases when your power and signal are not coming from the same location. In that case, you'd need to pair a black wire with the red wire, and the other black wire with the blue wire.)
Attach one black wire to GND, the red wire to 5V, and the blue wire to pin 3. I'm using an arduino micro in the picture. An Uno, Leonardo, etc should work similarly.
Step 5: Test It Out!
In your matrixtest file, find this line:
and change "Howdy" to whatever you want. Power up your arduino (I'm powering mine via usb in the picture) and give it a try!
Note: If you try a word longer than "Howdy", your word will be cut off. I'll leave it to you to read through the sample code and figure out how to fix that yourself! ;)