Charlieplexing LEDs

The Charlieplexing technique is named after its inventor, Charlie Allen, who invented the technique in 1995.

Most of the notes below came from a quick look at Charlieplexing by Brian Lough and Christmas Lights Special - Microcontroller Basics (PIC10F200) at circuitbread.com

Controlling a light-emitting diode (LED) is the hello world of electronics. Its often the first simple circuit we create.

The problem with doing this is it teaches us we need one General Purpose Input/Output (GPIO) pin to control something simple like our LED. For a Raspberry Pi which has 40 pins, 26 are GPIO so thats atleast 26 LEDs.

What if you need to control other things with those GPIO’s on the Pi or you have a much simpler micro controller such as the PIC10F200. The PIC10F200 only has 8 pins, of which 3 are GPIO so we would assume it can only control 3 LEDs.

With Charlieplexing it can in-fact control 6.

This is calculated with N * (N - 1) where N is the number of GPIO pins your controller has

1
2
3
4
N * (N - 1)
3 * (3 - 1)
3 * 2
= 6

How does this work?

I drew these diagrams using https://www.circuit-diagram.org/

For every pair of GPIO there are 2 LEDs placed in operside polarity, LEDs will only work when the current flows from their positive to negative. Charlieplexing exploits this so the LED can be connected in a circuit.

charlieplexing pairs AB

charlieplexing pairs AC

charlieplexing pairs BC

Using the diagrams above we will need to set the polaritys as follows to light up each LED (one at a time).

GPIO can be one of 3 states:

  • high voltage
  • low voltage
  • High z / high impedance
    • High z can be achieved by setting the pin as INPUT
    • High z is often marked as Z in tables for Charlieplexing

The truth table below shows the states above. Note that these diagrams show 1 resistor per wire but if the LEDs were all different colours they could have their own resistors to accommodate the voltage drop.

1
2
3
4
5
6
7
8
A     |     B     |     C     |     #LED
--------------------------------------------
LOW HIGH Z 1
HIGH LOW Z 2
Z LOW HIGH 3
Z HIGH LOW 4
HIGH Z LOW 5
LOW Z HIGH 6

4 GPIO

This would be 4 * (4 - 1) = 12 LEDs

4 GPIO pairs CD

4 GPIO pairs BD

4 GPIO pairs AD

Truth table expanding from the GPIO 3 table.

1
2
3
4
5
6
7
8
A     |     B     |     C     |     D     |     #LED
--------------------------------------------------------
Z Z LOW HIGH 7
Z Z HIGH LOW 8
Z LOW Z HIGH 9
Z HIGH Z LOW 10
LOW Z Z HIGH 11
HIGH Z Z LOW 12

References