First: LEDs are current-driven devices, not voltage driven.
An LED is a semiconductor diode, with a voltage to current relation like this:
The light output of an LED is related to the current driven through it, while the voltage remains more or less constant at the junction voltage Vf of the specific LED. (Note: For RGB LEDs, each of the R, G and B junctions has a different Vf).
They exhibit a sharp "knee" in their voltage to current graph. This is unlike incandescent lights which have a more linear V:I graph once they heat up (where brightness is more or less proportional to voltage).
Why this matters in current context:
Changing the variable resistance does not change the light output in an easily managed manner as you sweep the variable resistance:
- Until Vf for the relevant LED is reached across the LED leads, zero or a really small amount of light is emitted. Forward "resistance" of the LED is extremely high. Most of the supply voltage is across the variable resistor.
- As the resistance is reduced, at a point the voltage across the LED reaches Vf, and the LED lights up. Forward "resistance" of the LED becomes very low, so current flow increases very rapidly. The resistance of the variable resistor works as the current limiter of this circuit.
Vf appears across the LED
(Vsupp - Vf) appears across the resistor.
Current I = (Vsupp - Vf) / R
- When the variable resistance is reduced marginally further, the current flow goes beyond the LED's capacity without appreciable voltage increase, and the magic smoke comes out. Goodbye, LED.
See this answer to another LED question, for a better explanation.
Why PWM works:
In a PWM driven circuit when the PWM signal is in the "on" part of the cycle, the current is usually externally limited to a fixed amount (using a resistor, current regulator IC, whatever you like). In the "off" part of the cycle, the LED is simply off.
Thus, as the duty cycle of the PWM is changed, the LED is fully lit for part of the cycle, and off for the rest, as per the PWM ratio. Our eye blends this on/off combination (by persistence of vision) to arrive at the perceived light intensity.
PWM does not generate analog voltage levels from digital, our eyes (or external devices e.g. a capacitor) do the analog averaging.
So PWM will give you smooth control over intensity for each of R, G and B, a variable resistor will not. Smooth, but not linear...
A minor note to be aware of:
Our visual perception of luminous intensity is not linear. We perceive a small change in a low intensity light much more strongly, than a similar change of a higher intensity light. The Weber-Fechner Law provides more insight into this.
Also, this differs between colors, and between males and females (that's connected to how more men are colorblind than women).
Why this matters:
If you vary your PWM duty cycle linearly, the perceived light transition will not be linear. An exponential function of around x^2.5 is recommended for perceived linear intensity increase.
- Variable resistors won't give you the control you require.
- Even with PWM, linear variation of duty cycle is not ideal, exponential is better.
- For R, G and B of the LEDs, slightly different PWM transition curves would help.