Last active
April 27, 2020 14:48
-
-
Save ewust/7957372 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
(new Blinken({title: "Red Green", author: "ewust"})).run(function(lights) { | |
// variable that keeps track of if we are red (true) or green (false) | |
var strand_red = true; | |
// Set the strand to full brightness | |
for (i=0; i<100; i++) { | |
lights[i].a = 1; | |
} | |
// Return our update function | |
return function () { | |
// 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