Thursday, October 1, 2009

LED Matrix

Last year in one of my classes we were required to make an 'artefact' or something that reflects the interests of the class. Most people make posters and the past two quarters that's what my class did too. Posters however are static, usually boring, and don't reflect that fact that everyone in the class is an EE major. We decided posters are for noobs and decided to go off the wall a little and make an LED matrix display. Lucky one of my friends John Wathen already had this beautiful 16x24 Green SMD LED matrix that he built back in high school.



What we didn't have however was a driver for it. The driver we choose to design was highly inspired from this one. The basic idea is that you use shift registers to sink the columns and a line driver of some sort to source the rows (we chose to use a Darlington array).

There where a lot of changes from the Instructables design that that we had to make however. The matrix in the Instructables was a lot smaller than ours and used 8 IO lines to drive each row. Since our matrix has 16 rows this was completely infeasible using just an ATMega168. To solve this issue we choose to use a 4:16 de-mux to control all sixteen rows with only 4 IO pins. The de-mux combined with two 8 channel Darlington arrays provided the perfect interface to control all 16 rows. To sink the columns we choose to string three 8 Output shift registers. Each shift register is rated to handle the current of the 8 LEDs that could possibly be on at one time.

Some other features that we included on the driver board were 3 green LEDs, 3 push buttons, ISP header, TTL header. When all was said and done we ended up the the schematic shown below.


I know, you are probably looking at that and thinking, "Why are all the shift register outputs criss-crossed??". The reason for doing this is because the output pins on the chip are not exactly in a row so to assist in board layout the pins had to be crossed and mixed up so that the board layout would be nice. It's much easier to change the order of the columns in the program then it is on the board layout (in my opinion). We didn't want to etch a double sided board so a lot of effort went into laying as much of the circuit out on a single side. There were a few paths that could not be routed and were just jumped with wire (you'll see in picture below).


Notice how there are a bunch of air-wires (yellow lines) that I couldn't figure out how to route, they are manually jumped when the board is put together.

To etch the board we printed out the board layout 1:1 scale on glossy photo paper, it was than ironed onto a piece of copper clad. The idea is that the toner will stick to the copper clad and when the board is dipped in acid the acid will eat away at everything but the traces, since they are coved by the toner. I'm definitely not an expert in this area so ask John Wathen more about the process, he is basically a pro.

Etching the board in acid

Checking to see if its ready to be scrubbed

Dirty traces

Scrubbing off the rest of the toner

The beautiful result, nice and shiny

Now, let me just tell you that we did this in a public bathroom at school. So there were three guys in a bathroom with latex gloves, a camera, and tub of some green liquid. Trust me we got some weird looks.

The next step was to drill all the holes. I don't remember exactly how many there were (John might) but there were a lot.


After all the holes were drilled John soldered it all up.



And the result!











Now that the board was finished it was the moment of truth.

Adam Steele lent me his programmer. Plugged it into my Xbuntu box, apt-get installed the avr tool-kit and the programmer was immediately recognized (NICE!). Flashed a simple program to flash the status LEDs and low and behold, IT WORKED! Next up, everything else. I started by modifying the program that the Intructables provided but quickly got frustrated by the way it worked. It treated each column as a bit in a byte and the rows as a byte, this made it extremely hard to visualize outputs to the display. Also I was using a de-mux and had 24 columns which the code did not easy support. So what do you do in this situation? REWRITE.

An outline of how the new code works:

The value for each pixel is stored in a 2D array 16x24, want to set the top left pixel? buffer[0][0] = 1; simple as that, much easier than dealing with it as an array of bytes. Okay, so it takes up more memory but IMO it is completely worth every bit (pun intended).

The code starts by initializing the ports (pull-ups, in/out, etc) then it initializes timer1. To be completely honest the fill value for the timer was chosen by adjusting value, flashing, seeing if the refresh rate was noticeable. We ended up with OCR1A = 0x012C; as a good value.

The code then falls into an While(1) where it sequentially calls functions to draw stuff on the screen, for example:

All the high level functions (tunnel, spiral, shift, etc..) write to 'buffer'. When the timer interrupt goes off it calls the function shift_int() which reorders the columns into 'buffer_2' and then shifts them out to the shift registers. It then calls shift_mux() which jumps to the next row. So essentially we have a double buffered display.

Once all the low level code was done it was all fun and games. It was really nice being at the point were all you had to work with is a 2D array. We ended up with the high level functions:

It is so incredibly easy to make new functions when you are just manipulating a 2D array.

A warning before you watch the videos, they were taken with a crappy point n shoot camera so they look incredibly choppy. In real life the display is incredibly fluid and smooth. The videos do it zero justice.

Eagle Files & Source Code [Mirror]
If you re-use the design or source (which I encourage you to do) please give credit where credit is due. Also note that the entire code was literally written in a one night programming marathon since we were extremely pressed (read: it was due the next day), so there are still many bugs. Also I take no responsibility for any damage if you use my design and code (had to put a disclaimer ;))

Any questions regarding the design or the source code should be directed at me bear24rw .
Any questions regarding the construction of the board should be directed at John Wathen jmwathen .


  1. Wow! This is a fantastic effort. Great team work. Keep up the good work.
    John's mom

  2. Nice project. The driver design is pretty good. Here's a tip if you ever need more memory : make two functions, pixelOn and pixelOff to handle the bit level stuff, and use it like you would your buffer[][].

  3. This comment has been removed by the author.

  4. Really GREAT project!!! Thanks for free source and eagle files share!

  5. Dont worry, i´ve got some weird looks too. Specially when dealing with ultrasound and etching at the backyard.

  6. Superbious project! But how was the LED matrix made?

  7. @anon

    the matrix was made but laying it out in Eagle, and etching the board like described above. John then hand soldered all the SMD LEDs. You can contact him for more information

  8. Muito bom cara, parabéns

  9. ._. damn that must've taken so much coffee to hand solder all of those LEDs :p

    I've just recently bought 70 red LEDs (not SMD) to make a 14x5/8x8 matrix, and I'm wondering whether to get a perf board or make a custom PCB, any advice? :)

    Anyway, gre-... no, epic job! :D

  10. Hello, congratulations for the project.
    I would like you to send me the PCB LEDs, also would like to know
    would have to make many modifications to turn this cicuito and SMD-RGB
    basically what would be?

    Thanks, waiting anxiously for this reset,
    Luiz Antonio

  11. This post is appreciable as there is enough material in it for the readers. Thanks for nice sharing!

  12. Replies
    1. We didn't end up using them for anything in the final product. I just added them in case we wanted to use them for something in the future.

  13. Do you happen to have the schematic for the led panel as well?

    1. I do not. You can try contacting John. His email is at the end of the post.

  14. Eagle Files & Source Code not available in the link

  15. Hola el pcb si podría enviarme a mi correo

    Águila archivos y código fuente
    excelente Gracias de antemano

  16. TheeEagle Files and Source Code aren't available in the link. Can you send to

  17. TheeEagle Files and Source Code aren't available in the link. Can you send to

  18. Can you share how your friend made led matrix, I really want to know


  19. گروه تولیدی بازرگانی ال ای دی پانل با دارا بودن سابقه چند ساله در زمینه واردات ا
    ز کشور های مختلف و نیز تولید انواع تابلو روان و خرید تلویزیون شهری ، با به کاری گیری ن
    یروی متعهد و متخصص با هدف ارائه خدمات بازرگانی و تولیدی فعالیت می نماید که واحد
    بازرگانی شرکت ال ای دی پانل با دارا بودن شرکای تجاری معتبر در کشورهای چین ، تایوا
    ن و کره جنوبی اقدام به واردات کالاهای مورد نیاز من جمله انواع قطعات تابلو روان ، اجاره تلویزیون ش
    هری و تجهیزات نور پردازی با بهترین کیفیت و مناسب ترین قیمت مینماید و نیز واحد تولید شرکت ا
    ل ای دی پانل فعالیت خود را در زمینه ساخت و تولید انواع تابلو روان و تلویزیون شهری با مشخصات مختلف
    و نیز تولید انواع فریم و کابینت تابلو روان led و فروش تلویزیون شهری می نماید.امید است با همک
    اری و همفکری و انتقادات سازنده و گرانبهای مشتریان محترم تابلو led و خرید تلویزیون شهری و نیز همکارا
    ن محترم همواره شاهد ارائه خدماتی عالی و پشتیبانی واقعی از طرف گروه توليدي با
    زرگاني ال ای دی پانل باشیم.

  20. I wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the new stuff you post.
    Flush Mount Lights

  21. I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much. halco lighting technologies

  22. This blog is nicely written and I found the content and information very informative as well as helpful.
    best c online course
    online oracle
    c course
    cheap website design in chennai
    big data training online

  23. Excellent post, Thanks for sharing this.

    Learn more about our courses to get the best knowledge. CSPO Certification