Controlling Two LEDs per uC pin

3. Two LEDs in a 5 volt circuit

If Circuit 2.1 is used with a 5v supply, both LEDs will light up. That's because VCC/2 (2.5v) is more than the 1.9v VF that our standard red LEDs need to light.

Solution 1

Simply use LEDs with higher VF values. There are some lovely blue and white LEDs with VF values placed sensibly between 2.5v and 5v. They'd work very nicely.

But what if you don't want blue LEDs?

Solution 2

This time we'll still use the 'standard' red LEDs that have the 1.9 VF.

Somehow we want to reduce the 5v supply to something more 'low VF LED friendly'. We can use the fact that semiconductors drop voltage. What about using some diodes? Not the light-emitting kind this time.

A normal silicon diode will drop about 0.6v across it (again, I'm skipping merrily over some details here - further details are given in section 6.). Given that we want to drop about 2v from the supply, we can use four of them as follows.

Two LEDs in series with four diodes

Circuit Diagram 3.1

In this circuit, (remember that Vcc is 5v) neither LED_A nor LED_B light. That's because each diode (D1-4) drops 0.6v. This means that the remaining voltage differential seen across XY is only 5v - (4 * 0.6v) = 2.6v. This 2.6v across both LED_A and LED_B is not enough to light them.

So, how does this circuit behave if we connect a uC pin in between LED_A and LED_B...

Case 1: The uC pin is set to be an input.

As before, when the pin is set to be an input, it has no effect, hence the circuit is equivalent to circuit 3.1 and neither LED is lit.

Case 2:

The uC pin is set as an output with a high state (e.g. 5v). In this case, the circuit is equivalent to the following:

two LEDs, four diodes and a 'high' uC pin in the centre

Circuit Diagram 3.2

As you can see, LED_A is lit. That's because the voltage across is is 5v less the drops across D1 and D2. That's 5v - (2 * 0.6v) = 3.8v. LED_B is not lit as there's no voltage across it, i.e. both sides are at 5v.

Case 3: The uC pin is set as an output with a low state (e.g. 0v)

In this case, the circuit is equivalent to the following:

two LEDs, four diodes and a 'low' uC pin in the centre

Circuit Diagram 3.3

In this case, LED_B is lit. Similar to the previous case, it has 3.8v across it (this time diodes D3 and D4 drop the voltage). LED_A is not lit as there is no voltage across it; both sides are at Gnd.

Summary so far:

What I'm still ignoring:

I'll cover these points later.

For the moment, let's muddy the waters even more...