Controlling Two LEDs per uC pin

5. Current limiting resistors

OK, as promised, I'm finally here. Here are some back-of-fag-packet-calculations for you:

To calculate the resistor that each LED needs, we need to know:

Note: The "supply voltage to the LED" used in these calculations is VCC less 2 diode drops, because we're calculating the resistor required when the pin is controlling the LEDs. See Circuit Diagrams 3.2 and 3.3.

Vdrop is 0.6v
VCC is 5v
Vsup is VCC - (2 * Vdrop) = 3.8v
ILED is 20mA (most LEDs' datasheets say that this is a reasonable current).
VF is 1.9v
Vres is Vsupply - VF = 1.9v

Simple application of V=IR gives:

R = Vres/ILED = 95 ohms

"So where do I stick the resistor(s)?"

The resistor needs to sit between the centre of the two LEDs and the pin that controls them.

current limiting resistor location

Circuit Diagram 5.1

Normally it's not good practice to share a current limiting resistor between two LEDs, but in this case it's OK because we know that only one LED of the pair will ever be lit at one time.