There are many ways of driving LEDs and each has its merits for a particular application. Using a current limiting resistor is simplest, but then it’s sensitive to the input voltage so you don’t get constant illumination. Sometimes that matters. Constant-current LED drivers give us that consistency: a defined current no matter what the external conditions are (within specific operating conditions, of course). I like the two-BJT two-resistor driver: we use the fact that when a BJT is fully conducting its base-emitter voltage drop is near constant, like a diode’s. So, if we put a resistor in parallel with it, we will get a constant current going through it.
Dual-BJT constant current
Figure 1

Let’s look at the circuit (Figure 1). T2 has R1 in parallel with its base-emitter drop, so the current along R1’s path is IR1 = VBE(T2)/R1. When we apply power to the circuit, T1’s base gets current via R2 and starts to turn on, causing current to flow through our LED and R1. As current flows, R1 builds its voltage drop until T2 turns on and starts conducting as well. But we know that IR1 must be a near constant so any excess current that’s coming through T1 is “routed” through T2 in order to maintain that current. What we get is a constant current driver that’s largely unaffected by supply voltage levels and fluctuations.

The value of R1 needs to be exact, according to the current we want for the LED. R2 just needs to be in a range where it both allows enough base current for T1 to fully conduct (value not too high), and also allows the base of T2 to be able to divert enough current to maintain the constant current (value not too low).

Finally, VBE is quite sensitive to temperature, and this circuit is helpful here because while T1 can get hot by having higher current go through it ─ we’re not limited to driving 20mA LEDs with this circuit, that depends on the components’ ratings ─ the current through T2 is relatively constant, making its VBE quite stable.

Let’s discuss more of the subtleties of this circuit in the comments. What else can we say about it?
Additional Circuit Shorts, Info on BJT, and More
Interested in circuit design,BJT, and related topics? Subscribe to the "Circuit Shorts" tag for updates when new content is published. For a rapid prototyping solution, check out ElektorPCB4Makers. You can get two PCB prototypes in three working days!