Last active
April 27, 2020 16:42
-
-
Save ewust/7957194 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
// 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