Introduction: DIY 8 X 8 RGB LED Matrix With Controller
Unlike a monochrome LED Matrix, an RGB LED Matrix uses either Common Anode or Common Cathode LED. On the one hand, this simplifies matters somewhat, as you do not have so many connections and you can control a single set of Anodes (or Cathodes) in your multiplex of LED. On the other hand, this also means that an RGB LED Matrix is not simply an extension of a Monochrome LED Matrix, so I can't simply expand the controller to accommodate the additional LED colours.
Before I continue, let me just say that there are many different approaches to achieving an RGB LED Matrix and the approach that I have taken is, by no means, the best or only method. The method that I have adopted makes use of 4 x 74HC595 Shift Registers to control the switching on and off of the LED.
Initially, this instructable will deal with the physical construction of the matrix and controller as a "recipe" without any correspondence to the software side of the control for the matrix. I will touch on the software as a "conversation" and to give you an idea of where I am heading with the hardware.
I will, at a later date, delve more into the software for driving the RGB LED Matrix.
All parts were sourced from EBay
- 64 x 5 mm RGB LED.
- 16 x 220 ohm 0805 SMD Resistors
- 8 x 330 ohm 0805 SMD Resistors
- 4 x 75HC595N Shift Register
- 4 x 16 pin IC sockets
- 52 x 90 degree Male Pin Headers
- 15 x 90 degree Female Pin Headers
- Solid Core Copper Wire
- 1 piece of 3 ply wood (320 x 320 mm x 6 mm)
This is other stuff that I have used in making the matrix, such as a timber border for the plywood board. You might want to mount the board differently, so don't let me oppress your design id.
- 1 can of gloss white spray paint
- 2,000 mm 12 mm x 12 mm pine
- Wood glue (I use PVA)
When designing your LED Matrix, it's a good idea to sketch it out first so that you can work out some of the design problems before committing yourself and your resources to something that may just end up hanging in your workshop until you can find a use for it :) I have a couple of frames in my workshop that will languish there until I can come up with another project for them.
Step 1: The Matrix - Row and Column Connection
Underpinning the LED Matrix is the soldering of each LED in the matrix into columns of Anodes and rows of Red, Green and Blue Cathodes (for Common Anode LED).
The arrangement of the pins of your LED are critical to the predictable (and functional) working of the Matrix.
The first image shows the arrangement of the pins.
My RGB LED pins are
Red - Anode - Green - Blue.
The Red, Green and Blue pins are spread into a three tined (or pronged, if you prefer) fork. While the Anode pin is bent down and then across (as shown in the latter images).
To achieve this, I first measured out and drilled the 5 mm holes in the plywood. In my matrix, the holes are 35 mm apart and I have left a 20 mm margin around the board for affixing a border onto the panel (both for aesthetics and for imparting some rigidity into the 6 mm panel).
I then sprayed the upper side of the panel with a gloss white paint to give a good reflective surface for the lights.
The LED were then inserted into the panel from the back and the Cathode pins were bent into their forks.
I cut and stripped some solid core copper wire (from old telephony cabling) and soldered the rows together in their respective colours.
With the rows soldered, I then bent the Anode pins, leaving, a 3 gap between the Anode pin and the lower layer of Cathodes. I cut and fitted some shrink tube at the bend so that there was some protection from shorting.
Finally, I soldered the columns together and heated the shrink tube to "set" it.
With the rows and columns soldered, the next task was to test each LED and each colour to ensure that there were no short-circuits. Usually, this is seen as two LED coming on when only one should :) I did have some shorts in my connections, but fortunately, these were all as a consequence of the forceps used to hold the copper wire touching other row/column traces.
With the LED Matrix soldered, it's time for a well earned break.
Step 2: Controller - 4 X 74HC595 Shift Register
I have opted to make my RGB LED Matrix Controller using the 74HC595 Shift Register. This handy IC is often used to control 8 LED with the Arduino in a very simple Chasing Lights circuit. You can find any number of circuit designs on the Chasing Lights circuit on the interweb, so I won't go into much detail here.
Shift Registers take a byte of data (an 8 bit binary number) and send each bit to it's corresponding data pin (of which there are 8). Shift Registers can be "daisy-chained" together with the Serial Output feeding the next Shift Registers Data Input pin. Should you feed a 2-byte (16 bit) number to the network of Shift Registers, the 1st 8 bits are consumed by the 1st Shift Register and the 2nd 8 bit number is consumed by the 2nd, and so on.
I have designed my daisy-chain of Shift Registers to be modular - interconnecting "sister" boards, that is, each board has an input and output block of pins which can be connected together to make 4 boards in total.
The boards for the Cathodes are the same as each other, the only variation is that the Red Cathode board uses 330 ohm resistors, while the Green/Blue Cathode boards use 220 ohm resistors. This difference in Red versus Green and Blue is as a result of the difference in the forward voltage of the Red element when compared to the Green and Blue elements. If they all had the same value resistor, the board would be strongly red biased, so this is balanced by changing the resistor used.
The board for the Anodes is different again as it does not have any resistors, nor does it have an output block (this is the terminal board). The other difference is that the Anode Shift Register does not have the "Output Enable" pin connected, as it is not used in output.
The controller is expected to receive a 32 bit binary number from the microcontroller, which is handy, because Arduino doesn't directly handle > 32 bits (AFAIK).
The modularity of the boards also means that I can locate them more freely within an enclosure.
Step 3: Wiring the Matrix to the Controllers
I made a platform for the Controllers out of an off-cut piece of plywood and some timber stand-offs cut from the 12 mm x 12 mm pine from the frame. The platform serves two purposes:
- The platform allows easy and stable access to the controllers; and
- The platform provides a shield for the exposed wires, preventing them from being inadvertently pressed together and creating short-circuits.
The stand-offs were glued to the underside of the matrix and then the platform was screwed into the stand-offs. Each of the daisy-chained 74HC595 modules were then attached to the platform with 4 M3 nuts and bolts.
I'll make another of my Small Footprint ATMEGA328P board to drive the matrix and attach it to the platform.
This task is pretty much a procedural one.
It's important to progress methodically and with some patience.
I started with the Anode (black) rows by measuring each wire in turn, stripping, tinning and adding a Du Pont female connector at one end and then soldering the wire to the appropriate row. As I went, I fitted the Du Pont connector into an 8 pin Du Pont Housing and then tested each anode wire as I went.
As I am a little bit OCD, I made sure that I had a heat sink clamp attached to the row when I soldered the line to the row of anodes so that I could be sure that I wouldn't overheat the LED while I was still constructing. This was probably a little bit of overkill as I was not applying heat for more that 1.5 seconds and my iron was set to 320 degrees. The likelihood of heat damage was very low. But, then again, replacing a burned out LED in this matrix would be a pain in the butt.
After soldering the Anode rows, I then moved on to soldering the Red, Blue and then Green columns. When I was soldering the columns, I passed the wire under the anode line so that there was an isolated spacer separating the anode from the cathodes ... although, that doesn't protect the other anode rows.
With the platform, circuitry and wires the clearance that I need behind the LED matrix is approximately 30 mm. When I come to building the housing for the LED Matrix, I will need to make allowance for this in my design.
Step 4: Add the ATMEGA328P Micro
I've made a Small Footprint ATMEGA328P board to control the 4 x 74HC595 boards and fitted it onto the platform at the back of the matrix.
To connect the ATMEGA328P to the controller boards, I made a simple connector board with a couple of pin headers soldered to wires with a 5 pin Du Pont connector. This means that the connections to the controller boards is as low profile as I can manage (without soldering the wires directly to the ATMEGA328P board. I don't want to do that because I want to be able to plug in my ICSP add-on board to program the ATMEGA328P, maybe change the sketch, maybe add in some other jiggery-pokery (such as a WiFi module later on).
I've made use of MadWorm's PWM/SPI sketch to control the matrix, and I am very pleased to say that it works just peachy.
The last two images show the 8 x 8 RGB LED Matrix in action with the sketch.
All in all, I am very pleased with the results.
I hope that this instructable is useful for y'all.
Step 5: What's Next?
So far, the LED Matrix and Controller are independent of any software. The Matrix doesn't care about the controller, so long as it can send HIGH/LOW instructions, it isn't bothered.
The Controller doesn't care about the Matrix, nor does it care about the microcontroller. All that the Controller cares about is GND, Vcc (5V), Data, Latch, and Clock data. Where that comes from ... it doesn't care.
This is a classic case of functional abstraction. Each of the components manage their own functionality.
Before I start coding, I need to work on manufacturing a case for the LED Matrix. The overall design is still an open question. I am building the LED Matrix as a fairly simple piece of wall art, so the case design that I am leaning toward is a fairly standard square "shadow box" frame.
In terms of my design goals for the software to run the LED Matrix, initially, I am going to work on a simple bit of control where each colour is either On or Off. When I have that working, I will start working on a design using Pulse Width Modulation (PWM) so that I can have each of the colours on for a given percentage. As the Arduino doesn't allow me to do this via hardware PWM, I will have to implement software PWM ... luckily for me, there are some pretty good libraries and examples for that out there.
Anyway, I will see you all soon.