This is just another one of those posts based on some idea I recently learned about and thought was kind of neat...
Basically I have a project I'm working on that uses a large number of LEDs to be controlled by a microcontroller... So the question is, how many LEDs can you drive from a microcontroller with a total of (N) I/O pins?
A very simple approach would be to say, you've got (N) I/O pins, so put one LED on each and you can drive (N) LEDs with it...
A more aggressive approach would be to form the LEDs into a grid, and assign half the I/O pins to anodes and half to cathodes - then you can drive a total of (N^2 / 4) LEDs in a square grid...
Now, this whole thing can go one step further by taking advantage of two characteristics of the LEDs and the I/O lines:
1: LEDs are diodes, and so normally pass current in just one direction
2: I/O lines set as inputs will neither drive nor sink a significant amount of current.
This gives you nearly four times more LEDs in the grid: (N * (N - 1)) total. The grid grows such that each I/O line corresponds to a row and a column... You light an individual LED by setting its column "high" and its row "low" and setting everything else as inputs.
There are several downsides to this approach: wiring and programming the grid is more complicated, any wiring problems can result in hard-to-diagnose problems, and this approach is really only suited to driving one LED at a time. You can still scan through the matrix as you would with a regular LED matrix, but since you can only light one LED at a time, instead of a whole row, it gives each LED a much smaller duty cycle.
Wikipedia article on Charlieplexing...
Really, most of the time, it's probably just better to get more I/O lines, or use specialized LED drivers to handle a larger matrix - but it's a neat trick...
"Charlieplexing" - dense LED matrices
Moderators: Sparky, Moderators
"Charlieplexing" - dense LED matrices
---GEC (三面図流の初段)
There are no rats.
The skulls eat them.
There are no rats.
The skulls eat them.