I'm in the process of designing a controller PCB for a 10x10 white LED matrix clock (inspired by the tutorial here). It's based off an ATmega328 AVR IC and Maxim DS3234 SPI RTC.

However, I'm stuck: I have no idea how to control my custom non-standard 10x10 LED matrix. Originally I was going to use a Maxim MAX7219/7221 IC, but it can only drive 8x8 LED matrices. Then I was looking at some sort of charlieplexing solution with a ULN2803 darlington transistor array. The bright white LEDs I'm using need at least 30mA of current.

Here's my preliminary schematic (sorry it's not too clear, but note the I2C and UART lines are available for use): Schematic

Here's an example wiring schematic of my LED matrix (NOTE: the example diagram below only shows an 8x8 matrix. My matrix is 10x10.) LED matrix excerpt

What's the best way to drive my 10x10 LED matrix with the AVR? (Also, PWM is not a requirement, but would be nice.)


up vote 6 down vote accepted

The best example I can think of is the "Peggy," A Light Emitting Pegboard Display. It is a 25x25 LED matrix display driven by an ATmega168 (which is pin compatible with the ATmega328)

The wiki page has a lot of good information. Including a detailed schematic.

There are few things to notice in their layout.

For one, they use a row common anode setup. That is the current source is on the row, and sink on the column. You have yours in row common cathode. There is nothing inherently right or wrong with either layout. Just something to keep in mind when designing your circuit. If using discrete leds, it just means flipping the led connections. If using a prebuilt LED matrix, it is something important to know. (I'll assume you can easily swap the order to match the peggy schematic. If not, just swap column for row in your head)

They use 74HC154 4-16 decoder/demux chips for row select. Since you only need 10 rows (or cols) you can get away with just one. Of course, there is the issue of current. In your case, at 10 x 30mA = 300mA minimum. To solve that problem they used 2STX2220 PNP transistors which will be able to source up to 1.5A per row. A bit over kill in your case. Since you will just use these as row select switches, just about any other pnp transistor that can source your max current should work just as well. Take a look at Transistor Circuits to figure out what resistor values you'll need for full on/off operations.

On the Peggy board, for the column sink driver they use an STP16DP05. But I have found these difficult to find and expensive. There are many other alternatives like the TLC5916 These use a serial input, and can be easily cascaded. If not, a digikey of mouser search for led sink driver will yield many results.

Alternatively, since you already have ULN2803 arrays, you could use two of these with a single current limit resistor per column. That's a lot of pins, so you'll have to get creative, but it could work for the column sink as well.

Avago published a nice application note titled "Introduction to Driving LED Matrices". It covers this and a few other things.

When driving LEDs from port pins, a technique sometimes called "Charlieplexing" can be useful. Although some descriptions of it seem to be rather ad hoc, it allows N 3-state (high/low/float) port pins to drive (N*(N-1)) LEDs. here's an example using 4 port pins to drive 12 LEDs. The left-side switches are momentary and will pull an output high. The right-side switches are latching and will switch an output low. Note that the left-side switch associated with an output will only work if the right-side switch for that output is in the lower ("off") position.

The scope at the bottom shows the current through the second pin; as shown, pins will be called upon to sink about 15mA driving a column, or source about 5mA driving a row (a transistor will supply the balance of the current).

In practice, if one wanted to construct something like this circuit for a 10x10 matrix, one would electrically wire an 11x11 matrix with the diagonal missing, and "shove" the upper-right portion to the left a spot (yielding an 11x10 grid) and get rid of the bottom row.

  • 10x10 might be a bit too much for charlieplexing due to LED leakage currents, but it's worth a try. also, don't expect too much from a 1/100 duty cycle if you're trying to light all LEDs at the same time. – Stefan Paul Noack Apr 24 '12 at 10:19
  • CharliePlexing shouldn't require a 1/100 duty cycle. Just 1/11. Click on the circuit-demo link I provided. It's for an effectively 4x3 grid using four pins, each of which has a toggle switch to ground and (if not grounded) a momentary switch to VDD. – supercat Apr 24 '12 at 13:29
  • ah, I see what you did there! Neat trick with those transistors. this allows multiple LEDs to be used at once. – Stefan Paul Noack Apr 24 '12 at 14:06
  • @noah1989: It certainly helps with brightness, though for a 10x10 matrix if you have 25mA port pins it might not be strictly necessary; I've seen some LEDs which were really bright with 2.5mA. I find it interesting that all the discussions of Charlieplexing seem to think of an ad hoc matrix which is driven one LED at a time, when row-wise scanning is in fact fairly straightforward if the LEDs are arranged as indicated/described. I'm not sure Charlieplexing is necessarily a huge win versus using shift-register driver chips which can supply adequate current without external transistors... – supercat Apr 24 '12 at 15:36
  • ...and regulate column current without external resistors, but there is some elegance to the fact that the number of wires going to a board with "just" LEDs can be reduced (note BTW that on the circuit shown, the amount of current drawn from the CPU supply/pins could be reduced slightly if one has the resistors only connect to columns and transistors only to rows, but overall current consumption will not be affected by having them connected; since the CPU pins are being used to source a lot less current than they're sinking, it probably doesn't really matter. – supercat Apr 24 '12 at 15:39

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.