Home  About  Register  Login
Can You Control 12 LEDs Using 4 Pins? by John Main

If you have ever done any electronics before you will probably be familiar with multiplexing but charlieplexing adds a new dimension. It's a technique commercially developed at Maxim by Charlie Allen hence the name but you can still use the technique in your own circuits.

Note: The actual technique has been around for some time but Maxim is one of the first companies to use it in a commercial chip.

Multiplexing simply means sharing whether it is

FDM Frequency division multiplexing

TDM Time division multiplexing

WDM Wavelength division multiplexing

Of course the other form of multiplexing which every electronic engineer uses to steer signals around a digital circuit uses standard logic gates and although not as glamorous as FDM, TDM and WDM it is a core technique for designing digital circuitry.

With a normal logic gate multiplexer you will have a minimum of two inputs that you want to select and send to a single output controlled by a control signal.

The states of the output gates are as you would expect either high (logic 1) or low (logic 0) but charlieplexing recognizes another state:

High Impedance.

Note: This is the third state in addition to 0 and 1 so it is often called tri-state.

High impedance just means switching off the output current circuit so no current can flow into or out of the output pin.

Of course high impedance output logic gates have been around for as long as digital circuits have been used mainly for accessing a microprocessor bus where each device is tri-stated to disconnect it from the shared bus while another device outputs data to the bus.

Charliplexing

Charlieplexing uses the third state to disconnect a pin from a mesh of devices so no current flows at that node and it's ideally suited for control from a microcontroller since it's easy to change the operation just by re-programming the microcontroller.

One of the uses of charlieplexing is to control many leds using very few pins. LEDs are also diodes so reversing the voltage across an LED means no current will flow. If you connect two leds to two output pins with the second diode connected the opposite way to the first one (and using current limit resistors). Setting the output pins to 01 will turn on the 1st LED while setting the output pins to 10 will turn on the 2nd LED.

Now add in a third output pin and add two diodes connected between each microcontroller pin as before. You now have 6 LEDs and by tristating each microcontroller pin in turn only two output pins are 'connected' i.e. You can control each LED individually.

You have now controlled 6 LEDs using only 3 pins normally you would need 6 individual output pins.

The formula for how many LEDs you can control is:

LEDs = N * (N-1)

  • Two pins gives 2 x (2-1) = 2
  • Three pins gives 3 x (3-1) = 6
  • Four pins gives 4 x (4-1) = 12

Advantage of Charlieplexing

Very few pins control many LEDs.

Disadvantage of Charlieplexing

Only certain sets of LEDs can be turned on at the same time.

There is an article on Charlieplexing in the July07 newsletter from http://www.best-microcontroller-projects.com

This has a more detailed look at how to connect up the LEDs and shows truth tables to operate them.

John Main's website http://www.best-microcontroller-projects.com provides microcontroller resources and free projects which are fully documented including schematics and source code.


Other articles by John Main

The Robot Vacuum Cleaner - Top 10 Reasons to own a Roomba Robotic Vacuum - by John Main
A robot vacuum cleaner is the easy way to clean your floors automatically. At the push of a button it will clean a room in about an hour with no supervision.

Dimmable Fluorescent Lighting And Home Automation - by John Main

One of the first things you will want to do using home automation is to dim all your controlled lights to preset levels to set the so called scene. One problem is that you can't dim a fluorescent

Nohang - Can You Prevent A Hangover By Using Nohang? - by John Main

Cogeners

Cogeners are the main cause of a hangover and these are impurities in the drink. Some are left over as a result of the fermentation process while others are from the addition of flavour enhancing chemicals.

They cause inflammation

Newest Articles in Hardware

Protecting Data Against Power Surges - by Celeste Yates
It’s that time of year again in South Africa, where electricity becomes a gamble. It was this time last year when Cape Town was covered in darkness, at different times, in different stages. This year, hopefully it will not

What are the Differences between Laser Printer and Inkjet Printer? - by James Kara Murat
The differences between a laser printer and an inkjet printer are really based upon how you plan on using the printer. Unless you are planning to do quite a bit of quality color photo printing both the inkjet printer

What Is ERP SAP, Exactly? - by Jeffery Dodd
It is rather hard to pin down the meaning of ERP SAP. ERP, as we know, stands for Enterprise Resource Planning. In that case, what does SAP mean? SAP is an information technology acronym that when spelled out means

Save Money on Printer Cartridges for Your Home Computer - by Suzanne Arant-Wells
If you are running a home business, chances are that you are printing labels, invoices, reports, your own promotional materials, and other miscellaneous items. You may be using a lot of printer ink. Learn how to save money by refilling cartridges, or purchasing generic cartridges.

PCMCIA Sound Cards - The Standard in Sound Cards for Your Laptop - by Johan Friedman
If you're not entirely sure about the right sound card to buy for your laptop, then it's probably best to go with the standardized PCMCIA sound cards. PCMCIA stands for Personal Computer Memory Card International Association (PCMCIA). It's a