I got an error :
in function called from system Uncaught Error: Unknown Timeout at line 17 col 31 clearTimeout(timer);
in function called from system Uncaught Error: Unknown Timeout at line 17 col 31
clearTimeout(timer);
// 红外移动传感 FIR800 5v // http://www.espruino.com/Pyroelectric // Relay: low level trigger function run() { var timer; var pyreolectric = A0; var relay = A1; var delay = 20000; // 20 sec setWatch(function () { console.log("Movement detected"); LED2.write(1); digitalWrite(relay, 0);// trigger relay: ON if (timer !== undefined) { clearTimeout(timer); // debounce } timer = setTimeout(function () {// trigger relay: OFF LED2.write(0); digitalWrite(relay, 1); }, delay); }, pyreolectric, { repeat: true, edge: "rising" }); } E.on('init', run);
Does the code have some mistakes ? Help, thx!
@Sigma 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.
I got an error :
Does the code have some mistakes ? Help, thx!