Sometimes for simple applications you need to drive several LEDs. You would love to stick with tiny microcontroller that actually has few I/Os available. One solution could be using port expander that adds some complexity to overall project. Better solution is to use charlieplexing, when using special technique out can drive more LEDs than there are I/Os available.
Charlieplexing method allows driving N*(N-1) LEDs with N pins, so with 5 I/O pins of tiny microcontroller it is possible to control 20 LEDs. And you even need as many current limiting resistors as there are pins used. If you drive 20 LEDs with 5 pins then you need 5 resistors instead 20 when driving them directly. Probably main disadvantage of this method is a bit more complex program as it requires some encoding. So next time you need more LEDs in your project simply avoid grabbing bigger MCU and use this compromise.
For All Your PCB Need, One-stop PCB Solution Services Appear: