Update for Espruino board since it only has 3 lights... Also added ability to stop and restart it. Change the value of i to control how fast the lights change (in milliseconds), by default run=true, setting to false will stop it. You can now resume by setting run=true again. Enjoy!
var i = 1000, run = true;
function flashLights() {
LED3.write(false);
LED1.write(true);
setTimeout(function () {
LED1.write(false);
LED2.write(true);
setTimeout(function () {
LED2.write(false);
LED3.write(true);
setTimeout(function () {
if (run) {
flashLights();
} else {
var checkForRestart = setInterval(function () {
if (run) {
clearInterval(checkForRestart);
flashLights();
}
}, 500);
}
}, i);
}, i);
}, i);
}
flashLights();
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.
Update for Espruino board since it only has 3 lights... Also added ability to stop and restart it. Change the value of
i
to control how fast the lights change (in milliseconds), by defaultrun=true
, setting tofalse
will stop it. You can now resume by settingrun=true
again. Enjoy!