Skip to content

Instantly share code, notes, and snippets.

@nervusvagus
Created August 11, 2021 21:42
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 nervusvagus/708b8cd59242d70afdc75a5a6ce674ef to your computer and use it in GitHub Desktop.
Save nervusvagus/708b8cd59242d70afdc75a5a6ce674ef to your computer and use it in GitHub Desktop.
# include <FastLED.h>
CRGBPalette16 sweep = CRGBPalette16(
CRGB::Blue,
CRGB::Green,
CRGB::Green,
CRGB::Green,
CRGB::Green,
CRGB::Green,
CRGB::Green,
CHSV( 90, 255, 255),
CHSV( 90, 255, 255),
CHSV( 90, 255, 255),
CRGB::Yellow,
CRGB::Yellow,
CRGB::Yellow,
CRGB::Yellow,
CRGB::Yellow,
CRGB::Yellow
);
const uint8_t SweepSize = 15;
# define NUM_LEDS 100
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL, 6>(leds, NUM_LEDS);
Serial.begin(112500);
}
const CRGB BackgroundColor = CRGB::Red;
void loop() {
for (int sweepPos = 0; sweepPos < NUM_LEDS; sweepPos++) {
fill_solid(leds, NUM_LEDS, BackgroundColor); // wasteful but easy
for (int i = 0; i < SweepSize; i++) {
int pos = i + sweepPos; // if(pos > NUM_LEDS){ sweepPos = 0;}
// if(pos < 0) continue; // not on the strip yet
// Serial.println(pos);
pos += NUM_LEDS;
leds[pos % NUM_LEDS] = ColorFromPalette(sweep, (255 / SweepSize) * i);
// set color// past the end of the strip
}
for (int i = 0; i < SweepSize; i++) {
int pos = i + sweepPos + 30; // if(pos > NUM_LEDS){ sweepPos = 0;}
// if(pos < 0) continue; // not on the strip yet
// Serial.println(pos);
pos += NUM_LEDS;
leds[pos % NUM_LEDS] = ColorFromPalette(sweep, (255 / SweepSize) * i);
// set color// past the end of the strip
}
FastLED.show();
FastLED.delay(50);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment