Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <FastLED.h>
- #define NUM_LEDS 56
- #define LED_PIN 2
- CRGBArray<NUM_LEDS> leds;
- uint8_t patternCounter = 0;
- //wipe pattern colors
- CRGB bgColor = CRGB(0,0,0);
- CRGB wipeColor = CRGB(0,0,255);
- CRGB fgColor = wipeColor;
- uint16_t wipeStepTime = 20;
- uint8_t wipeStart; // wipe start pixel position
- uint8_t wipeEnd; // wipe end pixel position
- void setup() {
- FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
- FastLED.setBrightness(150);
- Serial.begin(57600);
- }
- void loop() {
- switch (patternCounter) {
- case 0:
- allBlank();
- break;
- case 1:
- sakura( leds);
- break;
- case 2:
- fillBlue();
- break;
- }
- EVERY_N_SECONDS(5) {
- nextPattern();
- }
- FastLED.show();
- }
- void nextPattern() {
- patternCounter = (patternCounter + 1) % 3; // Change the number after the % to the number of patterns you have
- }
- void fillBlue() {
- EVERY_N_MILLISECONDS(wipeStepTime) {
- fill_solid(leds, NUM_LEDS, bgColor);
- if (wipeEnd < NUM_LEDS-1) {
- wipeEnd++;
- fgColor = wipeColor;
- }
- else if (wipeStart < NUM_LEDS-1) {
- wipeStart++;
- }
- else if (fgColor == bgColor) {
- wipeStart = 0; // reset wipe
- wipeEnd = 0;
- fgColor = wipeColor;
- }
- else if (wipeStart == NUM_LEDS-1 && wipeEnd == NUM_LEDS-1) {
- fgColor = bgColor;
- }
- fill_gradient_RGB (leds, wipeStart, fgColor, wipeEnd, fgColor );
- FastLED.show();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement