Calculating resistor values for LEDs
Let's take a moment to talk about driving LEDs. There's plenty of information out there on how LEDs operate, and to be honest, we don't need to think about the majority of it. That's not to say that it's not a fascinating subject, but there's really only two properties we care about here—the forward voltage and the forward current. The forward voltage, also called the forward voltage drop or just voltage drop, of an LED is the voltage that is dropped across it, and the forward current is the maximum current that the LED can handle without being damaged. Both these values vary between different LEDs, but general purpose 3 mm and 5 mm LEDs like the one pictured previously will typically have a forward voltage of around 2 V and a forward current of around 20 mA.
The simplest way to limit the current through the LED to the desired forward current is by using a resistor in series with it. Let's take a look at the following...