How can I control 8 LEDs using only 5 pins of a microcontroller?
8 leds on/off have 2^8 = 256 possible states
5 control pins on/off have 2^5 = 32 possible states
Since 32 &lt; 256, and you can't use shift registers or i/o expanders, it would be impossible...
But if the 5 control pins are the pins of a MCU, you need to use only one of them for controling the 4 * 2 multiplexing process. One of the pins can be 0V or +Vcc, each of these two states enables a different set of 4 LEDs attached to the other 4 pins.
&quot;he gave us a hint : use a wire connection combination if a problem appears try solving it in your code&quot;
As this is a theoretical question in a curse, I think that this would be a possible correct answer. This is a kind of 2*4 multiplexing, using only 5 pins.
If you need to control a higher number of LED's, charlieplexing would allow to control untill 20 LED's.



simulate this circuit &ndash; Schematic created using CircuitLab