How To Control 12 LED's Using 4 Microcontroller Pins

If you have ever done any electronics beforeoutputs data to the bus.
you will probably be familiar with multiplexing butCharliplexing
charlieplexing adds a new dimension. It's aCharlieplexing uses the third state to disconnect a
technique commercially developed at Maxim bypin from a mesh of devices so no current flows
Charlie Allen hence the name but you can still useat that node and it's ideally suited for control from
the technique in your own circuits.a microcontroller since it's easy to change the
Note: The actual technique has been around foroperation just by re-programming the
some time but Maxim is one of the firstmicrocontroller.
companies to use it in a commercial chip.One of the uses of charlieplexing is to control
Multiplexing simply means sharing whether it ismany leds using very few pins. LEDs are also
FDM Frequency division multiplexingdiodes so reversing the voltage across an LED
TDM Time division multiplexingmeans no current will flow. If you connect two
WDM Wavelength division multiplexingleds to two output pins with the second diode
Of course the other form of multiplexing whichconnected the opposite way to the first one (and
every electronic engineer uses to steer signalsusing current limit resistors). Setting the output
around a digital circuit uses standard logic gatespins to 01 will turn on the 1st LED while setting
and although not as glamorous as FDM, TDM andthe output pins to 10 will turn on the 2nd LED.
WDM it is a core technique for designing digitalNow add in a third output pin and add two diodes
circuitry.connected between each microcontroller pin as
With a normal logic gate multiplexer you will havebefore. You now have 6 LEDs and by tristating
a minimum of two inputs that you want to selecteach microcontroller pin in turn only two output
and send to a single output controlled by a controlpins are 'connected' i.e. You can control each LED
signal.individually.
The states of the output gates are as you wouldYou have now controlled 6 LEDs using only 3 pins
expect either high (logic 1) or low (logic 0) butnormally you would need 6 individual output pins.
charlieplexing recognizes another state:The formula for how many LEDs you can control
High Impedance.is:
Note: This is the third state in addition to 0 and 1LEDs = N * (N-1)
so it is often called tri-state.- Two pins gives 2 x (2-1) = 2
High impedance just means switching off the- Three pins gives 3 x (3-1) = 6
output current circuit so no current can flow into- Four pins gives 4 x (4-1) = 12
or out of the output pin.Advantage of Charlieplexing
Of course high impedance output logic gates haveVery few pins control many LEDs.
been around for as long as digital circuits haveDisadvantage of Charlieplexing
been used mainly for accessing a microprocessorOnly certain sets of LEDs can be turned on at the
bus where each device is tri-stated to disconnectsame time.
it from the shared bus while another device