Skip to content

Instantly share code, notes, and snippets.

@ewust
Last active April 27, 2020 16:42
Show Gist options
  • Save ewust/7957194 to your computer and use it in GitHub Desktop.
Save ewust/7957194 to your computer and use it in GitHub Desktop.
// global variable that keeps track of if we are red (true) or green (false)
var strand_red = true;
function update(lights) {
// Loop over all the lights
for (i=0; i<100; i++) {
if (strand_red) {
// Set red
lights[i].rgb(1, 0, 0);
} else {
// Set green
lights[i].rgb(0, 1, 0);
}
}
strand_red = !strand_red;
// Wait 500 ms until we get called again.
return 500;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment