First of all: Suppose we want a nominal value of 20 mA through the LED, and suppose the "typical" LED characteristics are 2.0 volts across the LED at that current.

This is a very light load for the '2803, and the actual Vcesat will probably be on the order of 0.5-0.6 Volts.

So, the for 5 volts to the output circuitry, the voltage across your resistor will be something on the order of (5.0 - Vled - Vcesat) = (5.0 - 2.0 - 0.6) = 2.4 Volts

Then the resistance value would be (2.4 V) / (20 mA) = 120 Ohms

This is a nominal value based on "typical" characteristics of the '2803 for that particular diode.

Now, human eye response is quite non-linear, and a variation of plus or minus 10% (or even 20%) in the current of an individual LED may not be strikingly obvious, so using typical values is almost certainly OK.

Now the for an input voltage of 5 V, the input current for 20 mA output current is going to be something on the order of 1.5 mA according to the characteristic curves. This can be (cheerfully) supplied by your ATmega with no base resistor required.

The hfe is a dynamic current gain, operating in the linear region, and says that a change in input current causes the output to change by 1000 times as much. What that means for us, since we are not biasing the device to operation in the linear region, is that it won't stay in the linear region for very long as input current goes from zero to 1.5 mA. That's what saturation is all about.

This assumes, of course that you are applying enough voltage to the collector to make it operate saturated.

So: you have to apply a voltage that is at least 2.0 volts above Vcesat (the 2.0 volts is for the LED), and, maybe a little more to take into account worst-case conditions. Apply 5 Volts, and Bob's your uncle.

If you use a single transistor (2N2222, 2N3906, etc.) instead of the darlington pair, Vcesat for 20 mA collector current will be (typically) 0.2 volts - 0.3 volts, so you could easily use 3.3 Volts on the output circuit. With a plain old transistor, you would need a base resistor.

Regards,

Dave