Matrix LED testing

In the drive to be able to control more and more LEDs, there is the matrix format. Here’s a circuit diag from Kingbright that produce bulk devices. The circuit diagram is:


Here’s a picture of the device


35 LEDs in an 7 by 5 package, and so only 13 pins. And so can be driven (in theory) by 2 shift registers.

For example, if C1 is 5V, and pin 9 is 0V, then current flows through the top left LED and that LED is lit. In fact, if all of the R1 to R7 are 0V, all 7 LEDs are lit. So as long as the R? are high (i.e. 5V) and C? are low (i.e. 0V) everything is off.

So we can control this by driving a particular column high, and then Rx low for the LEDs we want to be lit. Current will then flow and the LEDs lit. And this can then be done for each column in turn. We can take advantage of the fact that human eyes are, in terms of temporal response, rubbish and just light the LEDs as quickly as we can, it’ll look like a static picture.

HC magic

The 74hc595 shift registers have a bit of magic in them. The outputs can be driven high, and we are used to the idea that a driven high output can supply current, i.e. be a current source. Upto 20mA, which as LEDs are fully lit with 5 to 15mA (dependent on colour), is nice. In addition, an output driven low can sink current. No connection to ground required. So an LED can be placed between two outputs; if one end is driven high, and the other low, it’ll light. Any of the other three cases, the LED would not be lit.


A couple of years ago, I built a circuit to test this, using a Kingbright matrix, 2 74595s and a PIC. Due to a shortage of DIP scokets, an excess of enthusiasm, and a lack of planning (read: not drawing a circuti diagram before putting together) some mistakes were made. I traced through what was made, and identified the mistakes.


Major thing to do here was to identify the mistakes. I then fixed up the board, and then it looked like



The code is then simple. With the circuit above, the idea is to drive each column high in turn, and set the rows to low for the LEDs that are wanted to be lit, and high the others. I used the same send_byte_to_595 and display_595() routines that I used for the Spoke Pov project, making sure to send the row first, and then the column. i.e.

void display_5x7_matrix(char v1, char v2, char v3, char v4, char v5) {






The main() is just then a repeated set of calls with the right values

    v1 = 0b00010000;
    v2 = 0b00100100;
    v3 = 0b01000000;
    v4 = 0b00100100;
    v5 = 0b00010000;

    while ( 1==1 ) {
        display_5x7_matrix(~v1, ~v2, ~v3, ~v4, ~v5);


The pattern is designed by my daughter as a smily face. And it works!

Demo image, along with design requirements from daughter.

Demo image, along with design requirements from daughter.

Interestingly, the different colours are not as obvious to human eyes as to the camera…

Code for this is on github as [to be filled in]

This was all a test. The idea is to push to a larger, homemade, matrix of LEDs for another project. But this circuit allows a little experimention with the “output enable” control pin to change brightnesses (the subject of a forthcoming post) and a general proof of concept of driving a matrix without having to wire up 35 LEDs…



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s