Does PWM save energy?

Posted on
  • Hey,
    I have a very battery-critical project and I want to save energy by dimming a few LEDs whenever I can.
    If I use analogWrite() to light the LEDS at half brightness, will it reduce power usage?
    What about using a potentiometer?

  • Which board are you using? It depends a bit on the chip you have on it.

    However one thing you can pretty much always do is pinMode(pin,"input_pullup")which turns on an internal ~40k pullup resistor, so will light the LED very dimly. You'll need to use "output" to use the LED for anything else though.

  • I'm using the Pico.

  • Ok, so you've got a few options really:

    • Hardware PWM (analogWrite) will reduce the power used by the LEDs, but it requires the high speed oscillator to stay on, which means the Pico will still be drawing 11mA. (setDeepSleep will stop the PWM)
    • Software PWM (analogWrite(pin,val,{ freq : 25, forceSoft : true })) will work with setDeepSleep(1) so strangely should actually draw less power on average - but ideally you want the frequency as low as possible to get the best out of it. You'll also be drawing more power the more outputs you're doing that on.
    • Using the pullups as above - it's by far the best, but will probably be really dim.

    I'm not quite sure what you meant about the potentiometer? If the LEDs all share a common line then you could put that on a potentiometer (or could do a similar thing with a resistor and the Pico) - the brightness would change depending on how many LEDs were on, but it would save a lot of power.

  • Why not dim the LEDs by using a higher value resistor? A lot of people default a few hundred ohms, when (at least indoors) modern LEDs are plainly visible (although dimmer) with even a 2.2-4.7k resistor in series.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Does PWM save energy?

Posted by Avatar for BootySnorkeler @BootySnorkeler

Actions