Delay is not a good way to manage time dependant tasks as it uses all the resources for itself You can do it this way:
var maxTime = 500; var maxStep = 10; var count = 0; var timer; var state = false; var blinkActive = false; function blink(){ state = !state; digitalWrite(LED1,state); if (!state) count--; if (count===0){ clearInterval(timer); blinkActive = false; } } function launchBlink(){ if(blinkActive === false){ count = maxStep; timer = setInterval(blink,maxTime); blinkActive = true; } } function onInit(){ clearInterval(); LED1.write(0); setWatch(launchBlink,BTN,{repeat: true, edge: 'rising', debounce: 100}); } onInit();
@fdufnews started
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.
Delay is not a good way to manage time dependant tasks as it uses all the resources for itself
You can do it this way: