Designing series/parallel arrays of LEDs and resistors is not that hard; you just have to know a few things:
- voltages add up in series
- currents add in parallel
- the current through elements in series is constant
- the voltage across elements in parallel must be constant
- if the sum of voltages across elements in series is equal to the supply voltage, no resistor is necessary
- the voltage drop across a resistor is defined by Ohm's Law -- V = I * R
- the power dissipated by an element -- P = V * I or P = I^2 * R for a resistor
- if the necessary resistance value is not a standard size resistor, round up to the nearest standard size (or use a resistor combination); tables of standard resistances here and here
- given the power dissipated by a resistor, round up to the nearest power rating
Other useful notes on equivalent resistances:
- for resistors in series: Req = R1 + R2 + R3 + ...
e.g. get 50 Ohm resistance from five 10 Ohm resistors in series
- for resistors in parallel: 1/Req = 1/R1 + 1/R2 + 1/R3 + ...
e.g. get 50 Ohm resistance from two 100 Ohm resistors in parallel
Now on to your issue in particular.
- The red, yellow, and amber LEDs have a forward voltage of 3V, so you could have 4 in series across the 12V supply with no resistor; 3 or fewer LEDs would require a resistor.
- all the other colors have a forward voltage >3V so with a 12V supply you could have at most 3 LEDs in series and a resistor would be necessary
- the forward current through those LEDs is the same regardless of color (if = 20 mA = 0.02 A) so you can mix and match colors within a series string, just be mindful of the voltages when calculating the resistance
To make an interesting example, let's say we want a red LED, blue LED, and pink LED in a series string with a 12V supply
VS = 12V, VL1 = 3.0V, VL2 = 3.4V, VL3 = 3.2V, if = 0.02A
voltage drop across the resistor:
VR = VS - VL1 - VL2 - VL3 = 12V - 3.0V - 3.4V - 3.2V = 2.4V
Rd = VR / if = 2.4V / 0.02A = 120 Ohm
This is a standard size resistor so:
R = 120 Ohm (if Rd were 123 Ohm, then we would have selected R = 130 Ohm)
The power dissipated by the resistor:
P = if^2 * R = 0.02A^2 * 120 Ohm = 0.048W (note: use actual resistance not the design resistance)
In this example, use a 120 Ohm 1/8 W (or higher power rating) resistor.Edited by radodrill - 4/20/11 at 10:06am