How to drive a lot of LEDs using PIC12F microcontroller

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

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.

drive a lot of LEDs from a few microcontroller pins

See also–The-theory/

Step 1

20 LEDs on 5 pins

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.

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.

Step 2


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.)

(1) “Charlieplexing – Reduced Pin-Count LED Display Multiplexing”

(2) “Tips ‘n Tricks 8-pin FLASH PIC Microcontrollers”

(3) Charlieplexing LEDs- The theory An Instructable by rgbphil

Step 3

Putting it to work.

drive a lot of LEDs from a few microcontroller pins Schematic

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.

Leave a Comment

= 3 + 3

Read previous post:
PIC RC Motor Controller (and example lego robot)

Step 1: Parts List General: RC transmitter/receiver set with at least 3 channels. As is this code only works with...

Scroll to top