Controlling Two LEDs per uC pin

4. Lots of LEDs from 5v

Just gaining one extra LED on a single pin isn't too exciting. Whilst we're probably not aiming for whole building illumination, we might want to scale this up somewhat. Let's aim for 8 pins controlling 16 LEDs...

"Do I really have to duplicate those 4 diodes for each pair of LEDs?"
"That's 32 diodes!"

Well, it turns out that you can share D1-4 for all of the LEDs...

16 LEDs sharing four diodes

Circuit Diagram 4.1

This circuit shares D1-4 with all the LEDs. (P0-7 are where the 8 uC pins are connected)

Each pin controls two LEDs, using the same logic as in previous sections. If the pin's an input, both its LEDs are off. If it's an output, then one of the two LEDs will be lit.

If you're starting to worry about how you're going to write code to control all those LEDs, don't. I'll give you some nice shiny code later on.