The code "works" ie it give me some nice LED's
The problem is, it stops working after a time.
// our main function
function puckLeds(){
let leds= 0;
let timerId = null;
digitalWrite([LED3,LED2,LED1], leds);
// watch for the Big Red Button
setWatch(function() {
if ( timerId !== null){
clearTimeout(timerId);
}
leds = (leds + 1)%7;
digitalWrite([LED3,LED2,LED1], leds);
timerId = setTimeout(function () {
digitalWrite([LED3,LED2,LED1], 0);
}, 10000);
}, BTN, {edge:"falling", debounce:100, repeat:true});
}
// ensure that the code is available after reload or whatever
E.on('init', function() {
console.log("hello");
puckLeds();
});
save();
Edit after input below.
Placement of pulldown did not seem to work
pinMode(BTN,"input_pulldown");
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.
The code "works" ie it give me some nice LED's
The problem is, it stops working after a time.
Edit after input below.
Placement of pulldown did not seem to work
pinMode(BTN,"input_pulldown");