break only works within a loop. "do every X seconds" in espruino is not implemented as a loop, but by setInterval(), which runs a callback every X seconds. Quite frankly, I don't think blockly is well equipped to represent this kind of thing - the way it deals with timeout/intervals is not really what you expect looking at it. To stop an interval, you use the interval number and clearInterval.
I think this does more like what you were looking for.
var inter; //used to store the interval number.
var lastval; //last thing we set C9 to, so we can alternate.
setWatch(function(e) {inter = setInterval(interFun,5000)}; ,C6,{edge:'rising'})
function interFun() { //this could be put into the line above, but this is more readable...
if (last==0) {last=1; analogWrite(C9,0.5);} else { last=0; analogWrite(C9,0);}
if (last==0) {
if(digitalRead(C7)==0 && digitalRead(A8)==0) {
clearInterval(inter) //done now - stop the interval from procing again.
}
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.
break only works within a loop. "do every X seconds" in espruino is not implemented as a loop, but by setInterval(), which runs a callback every X seconds. Quite frankly, I don't think blockly is well equipped to represent this kind of thing - the way it deals with timeout/intervals is not really what you expect looking at it. To stop an interval, you use the interval number and clearInterval.
I think this does more like what you were looking for.