Error message

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in menu_set_active_trail() (line 2405 of /home/qx/drupal-7.58/includes/menu.inc).

Driving LEDs

Contents: 

Resistors

LEDs are current controlled devices. The brightness of an LED must be controlled by setting the current through it, not the voltage across it. Like any other diode, the voltage across an LED changes little with the current through it and it varies between devices, so setting a constant voltage will probably result in the wrong brightness or a dead LED.

A typical green, yellow, or red LED drops 2.1V and has a maximum current of 20mA. In my experience, the brightness doesn't visibly change much above 10mA, and 5mA is often adequate. High-brightness and white/blue LEDs (white is blue with a yellow phosphorous coating) have different characteristics.

The resistance needed for an LED is:

R = (VSupply - VLED) / I

VLED is typically 2.1V. I is typically 0.010A.

This table shows the closest standard 10% resistor for each combination of supply voltage and LED current:

  5mA 10mA
3.3V 220 120
5V 560 270
9V 1.2k 680
12V 1.8k 1.0k

 

Multiple LEDs

Since your power supply approximates a constant voltage source and the LEDs are current controlled, each LED must have its own resistor. The voltage across two LEDs with the same current will not be the same due to manufacturing differences.

Treat each LED-resistor pair as a single unit.

Don't run multiple switched LEDs off of one resistor or the brightness will change dramatically as you turn the LEDs on and off.

LEDs in series work fine, but you have to have a high supply voltage. Use one resistor and add the voltage drops of all the LEDs to calculate the required resistance. There are LED driver chips which use a charge pump to generate a high voltage and then regulate the current. These are often used for white or blue LEDs in cell phones and PDAs because the available supply voltages may be too low to run even one LED.