Summary of How to drive a lot of LEDs from a few microcontroller pins.
This article explains how to drive N*(N-1) LEDs using only N microcontroller pins by leveraging their tri-state capability (+V, GND, high impedance). Unlike direct connection or traditional multiplexing, this technique allows an 8-pin microcontroller like the PIC12Fxxx or ATtiny11 to control 20 LEDs while retaining a pin for input. Known as "Charlieplexing," it involves driving one pin low for a row and setting remaining pins high or as inputs to light specific columns.
Parts used in Charlieplexing LED Drive:
- Microcontroller (e.g., PIC12Fxxx or ATtiny11)
- LEDs
- Pins configured for tri-state operation
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.
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.)
For more Detail: How to drive a lot of LEDs from a few microcontroller pins.
- How many LEDs can be driven with N pins?
You can drive N multiplied by N minus 1 LEDs from N pins. - Can an 8-pin microcontroller drive 20 LEDs?
Yes, a little 8 pin microcontroller like a PIC12Fxxx or an ATtiny11 can drive 20 LEDs on its five available output pins. - What is the advantage of Charlieplexing over direct connect?
A direct-connect approach consumes one pin for each LED, whereas Charlieplexing shares drivers to maximize outputs. - Does traditional multiplexing work well for processors with 5 or fewer outputs?
No, on a processor with only 5 or fewer outputs, traditional multiplexing barely gets you any more outputs than direct drive. - What are the three states required for the output pins?
The output pins must be active high, active low, and high impedence. - Who calls this technique Charlieplexing?
Maxim calls this technique Charlieplexing. - Where else is this technique mentioned?
Microchip also mentions this in their document and implements it on the PICKit 1 board. - How do you turn off an LED in this setup?
You leave the pins connected to the anodes as inputs to leave the LED off.

