Electronic – How to control three LEDs with two uC pins using just passive components

ledmicrocontroller

I only have 2 (3-state) pins available on a microcontroller and need to control 3 red LEDs, uC is running on 5V. I can only use passive components in addition.

Best Answer

To control four LEDs:

schematic

simulate this circuit – Schematic created using CircuitLab

To get both LEDs on a particular pin lit, toggle the pin at a few hundred Hz.

Note that this setup requires that the forward voltage of the LEDs be less than Vcc/2.

Note also that the resistors consume power all of the time, not just when the LEDs are on.