Intro: Build Your Own Programmable LED Matrix
QR codes are addicting. Smartphones are smart enough to read them from virtually any angle or orientation. But imagine taking it a step further. I had dreams of a digital LED array that I could program with QR codes, and I wanted it really big!
I used 16 matrices to create the QR code that is pictured here. You may purchase the kit to build an 8x8 panel from Jameco.
LEDs are not included to give you the freedom to choose your own size and color.
Step 1: Requires
Required tools and parts:
Soldering iron and solder
LEDs (10mm recommended)
Wire cutters and strippers
LED Matrix Kit Includes:
LED Matrix PCB
47 Ω resistors
Control Board PCB
150k Ω resistor
Pan head screw, 4-40x3/8"L
2x8 female header
Hex spacer, 4-40x7/16"L
1k Ω resistors
2x8 male header
Hex standoff, 4/40x3/8"
1.5k Ω resistors
Step 2: Install Pin Headers
Loosely fit the male and female header together and place the female header onto U1 of the control board and place the matrix board on top so the pins of the male header are visible through U1. The silkscreen should be face-up on for both boards.
Temporarily install a few spacers on the control board and stand the board pair on one side so both boards are square to each other. Tighten the spacers. This has an added benefit if you are building multiple matrices. They will all sit nicely flush next to one another.
Step 3: Install the Resistors
Solder all the resistors according to their value and silkscreen location on the control board.
R1 - R8 = 1k Ω (brown-black-red)
R9 - R16 = 47 Ω (yellow-violet-black)
R17 - R24 = 1.5k Ω (brown-green-red)
R25 = 150k Ω (brown-green-yellow)
Step 4: Install the Capacitors
Install both capacitors and note the markings on the silkscreen. Polarized capacitors must be positioned correctly or it will not work.
C1 = 10μF electrolytic capacitor and is polarized. Note the stripe indicating the negative side. The silkscreen shows a "+" sign for positive. Solder the capacitor with enough space that you can bend the capacitor over to lay flush with the board.
Step 5: Install Transistors
Match the tab on the side of the transistor with the tab of the silkscreen. There are three leads that should also match the orientation.
Q9 - Q16 = 2N2222A. Make sure each transistor says 2N2222A. (If it's something else, it could cause the opposite action to happen once programmed.
Helpful Tip: Solder one lead of each transistor at a time. This holds them in place and allows you to make minor adjustments. It also allows the transistors a brief period to cool before you solder the next lead.
Q1 - Q8 = IRF9Z34N. These transistors must be placed in the correct orientation. The sliver of a rectangle on the silkscreen indicates the backside of the transistor. Bend the leads back 90 degrees so the transistors will lay flat on the PCB when installed. You may also choose to leave a slight gap between the back of the transistor and the PCB for airflow to keep components cool.
Step 6: Install Socket and ICs
Note the notch on the PCB and the notch on one side of the socket. Match these notches up before soldering all of the pins. Install the Max7219 IC also noting the notch on the end near pin 1. You may need to square up the pins to get it to seat into the socket.
Step 7: Install the LEDs
Install one row of LEDs at a time. Solder one leg of each LED at a time so you can make minor adjustments to their position. Take your time. The straighter the rows, the better your display will look. The flat side of the LED on the silkscreen indicated the negative side. The shorter leg of an LED is negative.
Step 8: Install the Spacers and Standoffs
The standoff has threaded male and female ends while the spacers have only female threads. The spacers go between the control board and the matrix board, while the standoffs will thread into the spacers from the underside of the control board.
Step 9: Complete Wiring
Line up the pins of the headers from both boards and also the mounting holes of the PCB and press them together. Use the pan head screws to secure both modules together. It may be helpful to stand the two boards on the even side so they may be tightened when square to each other. Solder test leads to the pads on the underside of the control board, preferably with header pins on one end to connect to the Arduino.
Step 10: Program Your Arduino
I hooked up my matrix to an Arduino Uno, so if you have a different model, you may need to change the pins. Solder jumper wires to the pads on the back of the control board. There are pads for DataIn (DIN), Load, Clock (CLK), 5V (V+), and Ground (GND). Copy the sample code found on the Kit Instructions PDF to test the LEDs. (Also found at the end of this document.)
Connect the jumpers from the control board to the following pins.
DIN = DataIn (pin 12 on Arduino)
DOUT = DataOut (connects to next module's DIN, if applicable)
CLK = Clock (pin 11 on Arduino)
LOAD = Load (pin 10 on Arduino)
V+ = 5V pin if your power supply to the Arduino is greater than 5V, or connect it to VIN if your input power supply to the Arduino is 5V.
GND = Ground
If you are connecting additional panels, you will need to daisy-chain them as follows.
• DOUT from first control board (the one connected to the Arduino) connects to DIN of next control panel
• CLK connects to CLK on the next board
• LOAD connects to LOAD on the next board
• V+ can be connected together, but it is strongly recommended to supply power to each board's V+ independently to limit the amount of current flowing through the board
•GND can also be connected together, but for optimum operation, it is best to run independent ground lines to each board.
Step 11: Additional Programs and Patterns
Programming the LED panel can take a lot of time to figure out what LEDs you want on or off. You will need the LEDcontrol library installed into your Arduino's library folder. The library can be found here: http://www.wayoda.org/arduino/downloads/LedControl.zip More information on the LEDcontrol library for Arduino can be found here: http://www.arduino.cc/playground/Main/LedControl When you get into strings of panels to program, it may be easier to write some functions into an Excel spreadsheet to automate some of the programming, since the only thing changing are the panel being addressed and the LEDs that are on or off. My spreadsheet tool was designed for 16 LED matrix panels, chained together in two groups of 8.
The spreadsheet tool (Excel file near the bottom of the page) assumes there are 16 panels arranged 4x4, and the order as the Arduino sees it is left to right from top to bottom. Just place an "X" or other character in the cell you wish to light up, then click the "Build Code" button and it will create the code for Arduino and copy it to your clipboard. (Note: Your Macro security settings in Excel may need to be lowered to allow the button to run its function of creating the code.) The best method I found for the QR codes is to create one on another website, import the image and scale correctly so each dot has its own cell. Using the Picture tools, you can select the white cells as the "transparent color" that way you can see the grid of cells behind it. Use the keyboard to navigate between cells because the mouse will just click the image. Place an "X" everywhere you can see the cells and leave the black cells blank (OFF), and there you have it.
SAMPLE CODE FOR ONE 8x8 LED MATRIX
//This code below will turn on every dot of the matrix to test that all LEDs work.
***** These pin numbers are for the Atmega328P
* with Uno bootloader *****
* LedControl (name)=LedControl(DataIn,CLK,LOAD,number of Max7219) *
* pin 12 is connected to the DataIn to first cluster of 8
* pin 11 is connected to the CLK
* pin 10 is connected to LOAD
* number 1-8 up to 8 matricies
//we have already set the number of devices when we created the LedControl
//we have to init all devices in a loop
/*The MAX72XX is in power-saving mode on startup*/
/* Set the brightness to a medium value (1-15) */
/* and clear the display */
/* To determine which LEDs will be on, think of the row as having 8 positions with a specific number attached to each
(128, 64, 32, 16, 8, 4, 2, 1)
If you want every other dot ON in the row starting with the first, add the numbers located in the position you want ON.
(128 + 0 + 32 + 0 + 8 + 0 + 2 + 0) = 170. Use the number 170 in place of 255 below to turn on every other.
All the LEDs on in the row would be (128 + 64 + 32 + 16 + 8 + 4 + 2 + 1) = 255.
lc0.setRow(0,0,255); //255 sets all LEDs in the row to ON