Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Accessing palette via numbers instead of names. NOT WORKING!!!
- *
- * By: Andrew Tuline
- *
- * Date: January, 2021
- *
- * Reference: https://github.com/cloudwalking/tree/blob/master/tree/tree.ino
- *
- * There DOES, however appear to be a problem, because palettes[1] is black.
- *
- */
- #include <FastLED.h>
- #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
- #define LED_DT 12
- #define COLOR_ORDER GRB
- #define LED_TYPE WS2812
- #define NUM_LEDS 30
- #define BRIGHTNESS 64
- struct CRGB leds[NUM_LEDS]; // Initialize our LED array.
- const TProgmemRGBGradientPalettePtr palettes[] = {
- (TProgmemRGBGradientPalettePtr)PartyColors_p, // 0 purple yellow red orange blue
- (TProgmemRGBGradientPalettePtr)CloudColors_p, // 1 blue white
- (TProgmemRGBGradientPalettePtr)OceanColors_p, // 2 blue cyan white
- (TProgmemRGBGradientPalettePtr)ForestColors_p, // 3 green blue
- (TProgmemRGBGradientPalettePtr)LavaColors_p, // 4 yellow orange red black
- (TProgmemRGBGradientPalettePtr)HeatColors_p, // 5 yellow orange red white
- (TProgmemRGBGradientPalettePtr)RainbowColors_p // 6 rainbow
- };
- CRGBPalette16 currentPalette;
- void setup() {
- Serial.begin(115200);
- LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS);
- FastLED.setBrightness(BRIGHTNESS);
- } // setup()
- void loop () {
- uint8_t palette_num = (millis()/2000) % ARRAY_SIZE(palettes);
- currentPalette = palettes[palette_num];
- Serial.println(palette_num);
- fill_palette(leds, NUM_LEDS, 0, (256/NUM_LEDS)+1, currentPalette, 255, NOBLEND);
- FastLED.show();
- } // loop()
Add Comment
Please, Sign In to add comment