Last active
August 29, 2015 14:02
-
-
Save dasniko/6db26bc8242155741a63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var interval = 50; | |
startRaffle = function() { | |
[LED1, LED2, LED3].forEach(function(pin) { | |
setInterval(function() { | |
digitalWrite(pin, Math.random() > 0.5); | |
}, interval); | |
}); | |
}; | |
stopRaffle = function() { | |
clearTimeout(); | |
}; | |
runRaffle = function() { | |
s = !s; | |
console.log("lights are " + (s ? "running" : "stopped")); | |
if (s) { | |
startRaffle(); | |
} else { | |
stopRaffle(); | |
} | |
}; | |
setWatch(runRaffle, BTN, {repeat: true, edge: "rising", debounce: 1}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment