Skip to content

Instantly share code, notes, and snippets.

@marmilicious
Last active April 23, 2017 17:31
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 marmilicious/33c1c1ab7b66535c8b9e662efae4a23f to your computer and use it in GitHub Desktop.
Save marmilicious/33c1c1ab7b66535c8b9e662efae4a23f to your computer and use it in GitHub Desktop.
boolean goForward = true;
void loop() {
static uint8_t hue = 0;
static uint8_t count = 0;
//if (goForward == true && count < NUM_LEDS) {
if (goForward == true) {
EVERY_N_MILLISECONDS(15){
for(int i = 0; i < NUM_LEDS; i++) {
leds[i] = CHSV((hue++ + 20), 255, 255);
FastLED.show();
fadeToBlackBy( leds, NUM_LEDS, 250);
}
count++;
}
if (count == NUM_LEDS) { goForward = false; }
}
if (goForward == false) {
// Now go in the other direction.
EVERY_N_MILLISECONDS(2){
for(int i = (NUM_LEDS); i >= 0; i--) {
leds[i] = CHSV((hue++ + 20), 255, 255);
FastLED.show();
fadeToBlackBy( leds, NUM_LEDS, 250);
}
count--;
if (count == 0) { goForward = true; }
}
}
}//end of main loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment