Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Simple rainbow march using palettes
- *
- * By: Andrew Tuline
- *
- * Date: January, 2018
- *
- * This rainbow march uses palettes instead of the standard rainbow.
- *
- * This routine uses millis() instead of the dreaded delay statement for timing. As a result, the frame rate will be high
- * so that button or other polling routines can be added in the future.
- *
- */
- #include "FastLED.h" // FastLED library.
- // Fixed definitions cannot change on the fly.
- #define LED_DT D4 // Data pin to connect to the strip.
- #define COLOR_ORDER GRB // It's GRB for WS2812 and BGR for APA102.
- #define LED_TYPE WS2812 // Using APA102, WS2812, WS2801. Don't forget to modify LEDS.addLeds to suit.
- #define NUM_LEDS 30 // Number of LED's.
- struct CRGB leds[NUM_LEDS];
- CRGBPalette16 currentPalette = PartyColors_p;
- void setup() {
- delay(1000);
- LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS);
- } // setup()
- void loop () {
- rainbow_pal();
- FastLED.show();
- } // loop()
- void rainbow_pal() {
- uint16_t locn = millis()/20;
- uint8_t hueChg = 5;
- for (int i=0; i<NUM_LEDS; i++) {
- leds[i] = ColorFromPalette(currentPalette, locn + i*hueChg, 255, LINEARBLEND);
- }
- } // rainbow_pal
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement