Skip to content

Instantly share code, notes, and snippets.

@scheib
Created October 24, 2017 22:52
Show Gist options
  • Save scheib/f379c01844c1e06e73f9dafeb69c2d1d to your computer and use it in GitHub Desktop.
Save scheib/f379c01844c1e06e73f9dafeb69c2d1d to your computer and use it in GitHub Desktop.
puck.js program to blink lights
function setLed(n) {
LED1.write(n === 1);
LED2.write(n === 2);
LED3.write(n === 3);
}
function blinkCount(n) {
if (n === 0) {
n = 5;
}
var led = 0;
var count = n;
var interval = setInterval(function() {
led = (led + 1) % 4;
setLed(led);
if (led === 0) {
count -= 1;
}
if (count === 0) {
clearInterval(interval);
setTimeout(function() {
blinkCount(n - 1);
}, 1000);
}
}, 200);
}
blinkCount(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment