LED Dos and Don’ts

Print Friendly, PDF & Email

LEDs (short for light emitting diodes) are useful when learning how to program an Arduino board. They provide immediate visual confirmation that what you thought you programmed really works the way you intended.

It is very important, however, that you realize a fundamental limitation about how LEDs work, or you can destroy them and perhaps your Arduino board as well. The bottom line is this:

Never connect an LED directly to a source of voltage without a resistor in series with it to limit the current!

If you do connect an LED directly to a voltage source, the current flow will be very high for a very short period of time before the LED self-destructs. This high current flow can also damage your Arduino microcontroller chip.

The reason for this is clear when we look at the V-I Diagram for an LED. This is simply a plot of the current that will flow through the device as a function of the voltage applied to it:

For negative voltages (not shown), the LED passes almost no current at all, at least until the breakdown voltage is reached. For positive voltages, the current rises very steeply when a certain voltage is reached, the voltage varying with the color of the LED and also varying somewhat from LED to LED of the same type. As you can see, applying 5 volts to any color of LED is likely to cause a very high current to flow, having the effect of overheating and destroying the tiny LED chip.

By adding a series resistor, you can limit the current to a safe value. This diagram shows how to calculate the value of the resistance needed:

Vs is the voltage you are going to use (normally 5v with an Arduino). I sub f is the forward current you wish to flow (frequently 20ma for small LEDs). V sub f is the estimated forward voltage for your LED (1.2v for infrared up to 3.6v for blue). For example, to limit the current to 20ma from a 5v supply for a red LED with a forward voltage of 1.6v, use a resistor of (5.0-1.6)/.02a = 170Ω.

Here is a website link with more information than you ever knew you wanted about LEDs: http://lednique.com/ 

One interesting trick that I learned from this website is that your eyes cannot see infrared LEDs, but your smartphone camera can. The camera changes the infrared color to a shade of purple because of the different sensitivities of its red, green, and blue sensors. So if you want to know if your TV remote is working, shine it into your cell phone camera!