Ok, I officially am a JS noob...thanks for the explanation. At first I did not see the difference, but I saw what to check.
I kind'a get it now and this helped:
var glow=function(led, stp) {
var intensity=0;
var dir=1.0;
var this_led=led;
var this_stp=stp;
function intensity_step() {
intensity+=dir*this_stp;
if (intensity>=1.0) {
intensity=1.0;
dir=-dir;
}
if (intensity<=0.0) {
intensity=0;
dir=-dir;
}
analogWrite(this_led, intensity);
}
return intensity_step;
};
var led1=glow(D13,0.01);
setInterval(led1, 2);
Is that behavior a generic JS thing or the implementation of setInterval()?
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.
Ok, I officially am a JS noob...thanks for the explanation. At first I did not see the difference, but I saw what to check.
I kind'a get it now and this helped:
Is that behavior a generic JS thing or the implementation of setInterval()?