LED brightness can be controlled using digitally controlled potentiometer such as a Microchip MCP413X or a PWM signal. In both cases the signal will be controlled/ generated from a micro-controller. Which method is better using a digitally controlled potentiometer or PWM signal? Why?
3 Answers
The PWM solution is better under any aspect, plus the chip you linked has a quite high "full scale" resistance, $5\text{k}\Omega$, that will lead to use less steps than available.
PWM is better because its efficiency is near unity and because it does not require any external IC if the micro can handle the led current, which is usually true. When you use high power leds their drivers usually have a PWM input anyway, and a resistor would be impractical anyway because of the amount of power it should dissipate.
Digital potentiometers are used to attenuate an analog signal, such as a line level audio signal: you're trading some power dissipation for linearity. Such a signal is essentially a voltage signal, little to no current should flow so power dissipation in the resistors is not really a concern. When you want to power an LED instead you actually want power to flow into it, that's why you say "power an LED", and a resistor dissipates power, that's inevitable.
I'd just add a series fixed resistor to protect the led or to use the whole PWM scale, if that's a concern. A standard red led wants some 2V @5-10mA to work properly, a 3V3 output is enough to burn it, adding a series small resistor, in the $200\Omega$ range, allows you to set the pwm up to 100% and protects the led in case of an hw/sw fault.
This depends on your circuit. For efficiency, something that is often sought after with LED circuits, and especially things that run off batteries, the most efficient solution is to use PWM. Running a potentiometer works, but has more losses than the PWM setup, especially with a larger load. GreatScott! on YouTube provides a great explanation of this, but with a fan for an example:
PWM is more efficient than potentiometer, but on the other hand sometimes the flicker can be problematic. For example for filming video or when objects are moving fast, such as car headlights (PWM is prohibited for headlights in some countries).
You can also use a switching mode power supply (SMPS), which basically means adding an inductor and capacitor as a filter to the PWM signal to get a DC voltage / current going to the LED.