Created
August 11, 2021 21:42
-
-
Save nervusvagus/708b8cd59242d70afdc75a5a6ce674ef to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# 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