How to drive a lot of LEDs from a few microcontroller pins. using atmega

20 LEDs

Using the fact that many microcontroller pins have three states (+V, GND, or
“high impedence”, you can drive N*(N-1) LEDs from N pins. So the little 8
pin microcontroller like a PIC12Fxxx or an ATtiny11 can drive 20 LEDs on
its five available output pins, and still have one pin left for some kind of input.
The current crop of low pin-count microcontrollers (6 pins to 20 pins on
the whole package) are attractively priced and ‘cute’, but the question
arrises as to how you can make the best use of those pins for common
applications such as driving LEDs.

20 LEDs





A direct-connect approach to driving LEDs





consumes one pin for each
LED. A traditional multiplexing scheme where rows of LED anodes are
driven by one set of N pins and each row’s common cathode is driven by
another set of M pins manages to light N*M LEDs with N+M pins.
However, on a processor with only 5 or fewer outputs (as is the case
with most 8-pin microcontrollers), this barely gets you any more
outputs than direct drive.
Assuming the output pins are actually tri-state-able (active high,
active low, and high impedence (input)) it is also possible to share
the row and column drivers and control N*(N-1) LEDs with only N pins.
One pin is connected to common cathodes of a row of LEDs and driven
low, and the N-1 pins remaining are connected to the anodes and either
driven high to light that column, or left as inputs to leave the LED
off. Maxim calls this technique “Charlieplexing”, and describes it in
(1); Microchip also mentions this in their document (2) (and
implements in on the PICKit 1 board as well.)

Putting It to Work.

This drives 20 LEDs from an ATtiny11. An earlier version of this board was
actually built and appears as the main page photo. I’m afraid the picture
of the schematic is pretty hopeless; you need Eagle to tell you which signals
are connected where.

Since most of the board is taken up by the LED array, we can make room
for either a Attiny chip OR a microchip PIC12F chip. Shrink the LEDs down
to 3mm and go to a double sided board, and we get something about 27x44mm

Alas, this board hasn’t been tested yet…

Microchip of course has their 6 pin PIC10F chips, capable of driving a
mere 6 LEDs from the 3 output pins. This is about 16mm in diameter.
Going to 603 LEDs lets you get a bit smaller, but I’m not sure what’s the point.

Read more: How to drive a lot of LEDs from a few microcontroller pins.

Leave a Comment

Your email address will not be published. Required fields are marked *