January 8, 2015

LED basics

A light-emitting diode (LED) is a diode which emits light when activated. To limit the current flowing into the diode, it is important to introduce a current-limiting resistor in the loop.

The value of the appropriate resistor can be calculated with the following formula:

R=(V-Vd)/Id

where Vd is the voltage drop and Id is the current you want to use on your LED, usually the forward current. Those values depends on the specs of each LED and varies depending on the color of the LED.

So… you just want to light up an LED. What resistor should you use?

We can can make some rough assumptions to simplify the calculation:
• Common LEDs runs at 20m.
• The voltage drop is typically around 3V.
• Arduino runs at 5V
This lead to the following calculation:
R = (5-3)/0.02 = 100 (Ohm)

We can say that 100 Ohms is the absolute minimum resistance we need to make sure that we do not damage the LED. To be safe, it's a good idea to use something a little higher, just in case your LED has slightly different ratings that what I've used here.
I always use 220 Ohm resistors because they are a safe choice for all kind of LEDs and are easy to find.

If you know the ratings of your LED (you can find it on the LED's datasheet) and you want to do this calculation yourself or use an online calculator like this or this.