Question
How many LEDs can I connect directly to the microcontroller output pins?
Answer
Using Charlie-plexing you can configure N lines to control N*(N-1)
LEDs.
Charlie-plexing uses the three states of microcontroller pins to
enable a large number of LEDs to be controlled. An LED is turned on by
configuring two lines as outputs and setting the LED anode high (Vcc)
and the cathode low (GND). An LED is turned off by setting either the
anode or cathode to a high impedance state (tri-state).
It is easy to see the LED operation by arranging the LEDs in a
matrix. For each output pin an LED row is created. For each row
columns are created using all the other output pins. To turn an LED on
the anode needs to be set high and the cathode needs to be set
low. This corresponds to setting the row input low and the column
input high.
The schematics shown are simplified and may require additional ballast
resistors or current drive circuitry.
Limitations
- It is only possible to have N-1 LEDs on at a time. The LED
duty-cycle is dependent on the number of rows. For example
a 10 row pattern has a maximum duty-cycle of 10% (assuming that
each row is addressed). At a 10% duty-cycle the LED brightness is reduced to
10%.
- Lighting all LEDs along a row or a column increases the output
current requirement. The current may exceed the total source/sink
capability of the microcontroller output. Sequentially lighting
each LED decreases the current requirement but also decreases the
LED brightness (since the duty-cycle is further reduced).
| Number of Pins | Number of LEDs
|
| 3 | 6
|
| 4 | 12
|
| 5 | 20
|
| 6 | 30
|
| 7 | 42
|
| 8 | 56
|
| 9 | 72
|
| 10 | 90
|
| 11 | 110
|
| 12 | 132
|
| 13 | 156
|
| 14 | 182
|
| 15 | 210
|
| 16 | 240
|
| 17 | 272
|
| 18 | 306
|
References
Lancaster, Don (2001)
Tech Musings, August, 2001
Retrieved May 2, 2010
wikipedia Charlie-plexing