Posts Bicolor led matrix with atmega8
Post
Cancel

Bicolor led matrix with atmega8

Hello,

Today I’m going to show you, how could I draw and play some animation on a bicolor 8x8 led matrix. Approximately a year ago, I found a used, but cheap matrix (it was about 2€). I think this is the most common pinout for the bicolor led matrixes:

So the schematic is is:

The control is rather simple. One line is drawed at once, but this line is changing very quickly. Thats why the human eye can see one still picture, not just blinking lines. Basically the matrix is driven by shift registers, vertically and horizontally as well. So it consumes only 4 IO pin (two for the data (hor. and vert.) and two for the clocks). The uC could be any attiny variant of the AVR family, but in this case, the AVR have to store all of the frames.

So one shift register controls the matrix vertically, followed by an UDN 2891 driver. This is needed because every line of the matrix has 16 leds (8 bicolor) and the current would be too high for one pin of the 74164 (I tried it, the matrix had almost no light). The first version of the project was build with a 3-8 demultiplexer to control the lines, but there was 6 IO pins needed, so this is more simple. OK, so we had one shift register to select the actual line, by sending one ‘1’ in, and then it just steps over the shift register with the clock of the IC. Once we have a line selected, we have to load is with data. For this, there are another two shift registers, at the bottom for the first eigth LED, then it’s last output supplies as the second register’s input (for the second eigth LED). By this, we got a 16 bit long shift register (their clock is common). Well, now we can load the data into the horizontal shift registers in 16 steps. We can load the last bit first (it will be pushed to the back by the data behind it, so the first is the 16th LED’s state), and so on. If it is loaded, the AVR waits for some time (a few msec) then goes to the next line. The frames practically stored in unsigned int arrays, because they are 16 bits/item long.

A few months ago I assembled one to my colleague as a present:

This board contained a MAX232 and a DB9 connector as well, to write custom programs on it, or just debugging, etc. So the hardware was already done and I had working code on it, but it was difficult to “draw” the frames by counting the bits in an integer array like this: {0x550,0x7ffd,0xfebf,0xfaaf,0xeaab,0xfaaf,0xfebf,0x7ffd} . I know this is not the best solution, I’m not so proud of it and anyway it is has dirty code, but I made a PHP script to, let’s say design :) frames in browser. Here it is. It has several buttons, by pressing a button, it generates a C array definition, what you can insert to the code (this is also attached to the project). You have to attach these generated lines, attaching them with a comma to keep C syntax.

I made a video of the prototype:

So thats all for today, I know it is a very basic implementation. My plan is to write some low level function to manipulate the content of the frame, then it will able to draw custom things what comes at runtime (process some audio input with fft like in Winamp or little ‘video games’, etc.)

Here is the code: led_matrix.zip

This post is licensed under CC BY 4.0 by the author.