I need help to turn on a buzzer at different intervals according to the variation in the input, I am currently simulating with a slider, but at the time of varying the interval is not deactivated, I attach the flow and function block
var msgHigh = {payload : 1};
var msgLow = {payload : 0};
var dato = {payload : 0};
var dato2 = {payload : 0};
function high(){
node.send(msgHigh);
}
function low(){
setTimeout(function(){
node.send(msgLow);
},1000);
}
if(msg.payload=="0"){
clearInterval(dato);
clearInterval(dato2);
}else if(msg.payload=="1"){
dato = {payload : setInterval(high,2000)};
dato2 = {payload : setInterval(low,2000)};
}else if(msg.payload=="2"){
clearInterval(dato);
clearInterval(dato2);
}else if(msg.payload=="3"){
clearInterval(dato);
clearInterval(dato2);
}
