Created
August 12, 2021 20:26
-
-
Save nervusvagus/e1ad05ba2e9975d48dbf1d05528deb20 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> | |
#define LED_PIN 10 | |
#define NUM_LEDS 300 | |
#define BRIGHTNESS 55 | |
#define LED_TYPE WS2812B | |
#define COLOR_ORDER GRB | |
CRGB leds[NUM_LEDS]; | |
int pos = 0; | |
const uint8_t SweepSize = 32; | |
//#define UPDATES_PER_SECOND 100 | |
CRGBPalette32 sweep = CRGBPalette32( | |
CRGB::DarkBlue, | |
CRGB::DodgerBlue, | |
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, | |
CRGB::Gold | |
); | |
void setup() { | |
delay( 3000 ); // power-up safety delay | |
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS); | |
FastLED.setBrightness( BRIGHTNESS ); | |
// FastLED.setMaxPowerInVoltsAndMilliamps(5, 2500); | |
} | |
const CRGB BackgroundColor = CRGB::Red; | |
void loop() { | |
FastLED.show(); | |
int sweepPos = (millis() / 40) % NUM_LEDS; | |
fill_solid(leds, NUM_LEDS, BackgroundColor); // wasteful but easy | |
for (int i = 0; i < SweepSize; i++) { | |
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 + (NUM_LEDS / 5); // 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 + (NUM_LEDS / 5 * 2); // 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 + (NUM_LEDS / 5 * 3); // 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 + (NUM_LEDS / 18); // 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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment