Without setDeepSleep(1), the Pico will be drawing 11mA, but the main oscillator will be running all the time. In that case, using analogWrite(PIN, 0.5)will use less power than digitalWrite, but it's still quite a lot.
If you have setDeepSleep(1) then the main oscillator will be off, so hardware PWM won't work. However the Pico will be drawing 0.02mA (so way less).
You could try: analogWrite(pin,0.5,{freq:50,forceSoft:true}) and setDeepSleep(1). That'll use software PWM, however because the chip is able to sleep properly for most of the time it may well be more power efficient.
Your other options are:
use pinMode(pin, "input_pullup") which will turn on the 40k Internal pullup resistor. It's not much but with modern efficient LEDs it can be pretty good - and it works great with setDeepSleep
I don't know if all your LEDs are wired in parallel or if you're scanning? One option is just to 'pulse' them every so often:
var LED_PINS = [ A0, A1, ... ];
setDeepSleep(1);
setInterval(function() {
digitalWrite(LED_PINS, value_to_display);
digitalWrite(LED_PINS,0);
}, 50); // 20 times a second
It's a bit like software PWM but it'll work much better with multiple LEDs.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi,
You're using a Pico? So it's an STM32...
http://www.espruino.com/Power+Consumption has some figures for power usage, but basically:
setDeepSleep(1)
, the Pico will be drawing 11mA, but the main oscillator will be running all the time. In that case, usinganalogWrite(PIN, 0.5)
will use less power than digitalWrite, but it's still quite a lot.setDeepSleep(1)
then the main oscillator will be off, so hardware PWM won't work. However the Pico will be drawing 0.02mA (so way less).You could try:
analogWrite(pin,0.5,{freq:50,forceSoft:true})
andsetDeepSleep(1)
. That'll use software PWM, however because the chip is able to sleep properly for most of the time it may well be more power efficient.Your other options are:
pinMode(pin, "input_pullup")
which will turn on the 40k Internal pullup resistor. It's not much but with modern efficient LEDs it can be pretty good - and it works great withsetDeepSleep
I don't know if all your LEDs are wired in parallel or if you're scanning? One option is just to 'pulse' them every so often:
It's a bit like software PWM but it'll work much better with multiple LEDs.