Sunday 26 February 2012

Arduino - How to power LED matrices using shift registers: Part 2

Welcome to part two.

This has all the steps you need to get your creations up and running. But first, the code for my program can be found here: http://dl.dropbox.com/u/16309910/test.ino or search for me on github: j-fray or clone it using https://j-fray@github.com/j-fray/Arduino---Simulating-bead-sort.git


There are also some pictures of the schematics which you can find here:
Imput layer: http://dl.dropbox.com/u/16309910/inputlayer.png
Output layer: http://dl.dropbox.com/u/16309910/outputlayer.png
Power layer: http://dl.dropbox.com/u/16309910/powerlayer.png

I will upload any remaining documents to my github as listed above.

Now obviously this program is meant for 6 matrices, but it should be pretty straight forward to alter it for any number of matrices.

Step 1 - Setup
A good place to start is to get one matrix up and running. You need 3 pins on your Arduino board, one for data, one for clock and one for load pins. With the MAX7219 these correspond to pins 1, 13 and 12 respectively on the shift register. Put the shift register on a breadboard and connect these up.

Then its time to connect the ground and power pins up. The ground pins on the 7219 are 4 and 9, the power pins are 18 and 19 (check the link to the schematic in part 1). Pin 18 needs to be connected to a 40KOhm resistor (or equivalent combinations) and then connected to the power supply.

Arduino boards in general have a 5V output and that's what I used, just make sure the pins are connected in series and not in parallel.

Step 2 - Connecting to matrix
Now to start connecting up the matrix. As mentioned in part 1 the pins mappings of LED matrices vary for each make so check the datasheet of your matrix to see what pins use what. In my case pins 1 - 4 and 20-24 control the rows.13-19 control the red cols and 5-12 control the green cols.

Connect your matrix up appropriately. It is worth uploading the program to the Arduino board first and connecting the pins one at a time so that you can see the matrix working and deduce if there are any problems with a particular row.

The result should be a small sequence on the matrix.

Step 3 - Repeat
Repeat steps 1 and 2 for however many matrices you want, remember to do small bits at a time and test them. The last thing you want is to wire the whole thing and find it doesn't work or you've wired it wrong.

Here are some pictures of my creation:




Schematics
Input layer

Output layer

Power layer




Common problems (I found)
Matrix kept turning off
The most common problem I had was finding the matrix would just randomly turn off and wouldn't turn back on until I reset the Arduino board. I found out this was due to the resistance of the resistor I was using. There is a handy table on selecting the value for this resistor (Rset) in the guide in part 1.

The matrix is displaying my sequence/pattern incorrectly
This is most likely due to connecting the pins up incorrectly. Remember to check the pin mappings for your matrix and whether its common cathode or anode.

My sequence will stop/freeze
This will probably be due to the delays used in the program. If its anything like mine there will be a delay at the start/end of the sequence code. Playing round with that should get it working again.

Any other problems you have you're welcome to ask me about them, but I can't guarantee I'll be able to solve your problem :)

Thanks for reading and I hope this was helpful

Jake

3 comments:

  1. have an 8x8 matrix (on a chess board) I am trying to drive from a Max7219 controlled by a Uno.

    I am using the matrix sketch that comes with the Ledcontrol library to test it. (see below)

    However I cannot get it to work:

    When I connect it all up and load the sketch, all the LEDs come on and stay on.

    I have checked all the wiring but it seems OK.

    Some observations:
    I am assuming that since all the LEDS come on I have the polarity correct, however the data sheet for the 7219 says it starts with the display clear (i Assume that means off)

    I have tried various combinations of the CLK, DIN & LD connections, but the result is the same.

    I note that you say a Pin 18 needs to be connected to a 40KOhm resistor (or equivalent combinations) and then connected to the power supply. However the wiring diagram in your link http://arduino.cc/playground/Main/MAX72XXHardware shows the resistor connected between 5v and Pin 18.


    Any ideas?

    ReplyDelete
    Replies
    1. Hi Max,

      If your LEDs are coming on and staying on, there's a chance that your matrices are not connected correctly. What matrix are you using? Check the datasheet, specifically whether its common cathode or anode and the pin mappings.

      I used the 5V pin on the Uno. It should then go to a resistor (you can play around with the value, but betweek 20k and 40k will do. Then that should go to the shift register.

      Does this help?

      Jake_F

      Delete

Did you find this post interesting?