I think the problem might be that when you change a software PWM value, it basically cancels the old PWM and then starts a new one - so you can get 'glitches' (the hardware handles this automatically and avoids it). The faster the frequency the less obvious the glitches are, but then the more work Espruino is having to do.
As you're doing your interval at 15ms, so 66 fps, you probably wouldn't see flicker if you just pulsed the pins at that rate.
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.
I think the problem might be that when you change a software PWM value, it basically cancels the old PWM and then starts a new one - so you can get 'glitches' (the hardware handles this automatically and avoids it). The faster the frequency the less obvious the glitches are, but then the more work Espruino is having to do.
As you're doing your interval at 15ms, so 66 fps, you probably wouldn't see flicker if you just pulsed the pins at that rate.
How about replacing:
with a set of:
You might find you could use
setInterval
with a period of 10 (and then set15
to10
above as well), and that could make a be compromise?