NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » LED 8x8 Matrix help

October 02, 2011
by missle3944
missle3944's Avatar

Hi guys I just bought an 8x8 dual color led matrix off ebay. I want to do something similar to the nerdkits led marquee. But I'm a little confused on the coding side of things. I have all of the pins hooked up the the MCU pins. But I'm just wondering is how I would setup an array and then have the MCU read off the array to display the picture or what not. I mean something like this:

int h[8][8] = {
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,1,1,1,1,0},
{0,0,1,1,1,1,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0},
{0,0,1,0,0,0,1,0}};

But I dont really understand how I assign port values to each row and column. I found a arduino code for it here. I can see that he sets up a counter for the program so it knows what column and row to go by.

Heres some pics of it! Though for some reason the Red LED in 3 of the dots are not working. Crappy chinese things!

when its not lit up

when it is

October 02, 2011
by Rick_S
Rick_S's Avatar

An easy way is through shift registers like the 74HC595 or 74HC164. The shift register would control the columns and then you can drive the rows with a mosfet / row or the ULN2803 device you have. What you do is set up a timer that will turn off all rows, load the data into the shift register for the row you want to light, then turn on the row. At the next timer interval, you repeat the process for the next row and so on. In between the row refreshes, you do whatever other processing you need.

Then Nerdkit LED array project does a lot of this but without the shift registers. If you look at my Different LED Array post, I've modified the code for a board I purchased that used 74164 shift registers and mosfet drivers.

LED arrays can be lots of fun to play with. Good luck!

Rick

October 02, 2011
by missle3944
missle3944's Avatar

Alright,

Thanks Rick for the suggestion. I just bought some 74HC595 shift registers from ebay. Actually I had to buy 10 of them for the price of $3.00 total! I'm looking forward using them with the LED matrix and getting some good experience with them. I think I just need to get the timing part down now for programming the matrix. I'll get back to you guys once I get them in.

-Dan

October 05, 2011
by missle3944
missle3944's Avatar

Hi all,

I just got the 595's in the mail. I hooked one up to the column side of my 8x8 LED matrix and it works GREAT!!! I loaded up Rick's code that he posted for the photography project to test it out. Thanks for writing that code Rick! Much appreciated. Should I hook another 595 to the row side or should I just have each row hooked directly up to the MCU pins? Now it is time for some good ole timing.

I suppose I should use a counter for the timing as you did Rick for the LEDs. But I don't really understand how to time the row and columns together. Any suggestions are much appreciated :)

-Dan

October 06, 2011
by Rick_S
Rick_S's Avatar

Download the code from the link I posted above and look it over. It is written for a matrix. If you have things working though, just in your timing loop, turn off all rows, load a rows worth of data into your shift register, turn on the row you just loaded. Next timing loop, increment row, turn off all, load next row of data, turn on current row. repeat... Do whatever else during time between refresh.

Rick

Post a Reply

Please log in to post a reply.

Did you know that a piezoelectric buzzer can be used in reverse as a microphone? Learn more...