Skip to content

Instantly share code, notes, and snippets.

@dasniko
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dasniko/6db26bc8242155741a63 to your computer and use it in GitHub Desktop.
Save dasniko/6db26bc8242155741a63 to your computer and use it in GitHub Desktop.
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