I'm controlling a Raspberry Pi with a bot and I'm simulating all the functions before implementation.
function onFunction() {
console.log("LED ON");
}
function offFunction() {
console.log("LED OFF");
}
// blink:
function loop(){
onFunction();
setTimeout(offFunction, 500);
setTimeout(function(){ loop() }, 1000);
}
I need this loop to stop when I call another function:
bot.hears(/off/i, (ctx) => {
//break blink;
offFunction();
});
I was trying to use a label and break but it doesn't seem to work with functions. Only with for, while loops.