Skip to content

Instantly share code, notes, and snippets.

@carlynorama
Created January 8, 2021 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlynorama/a60ffd752ee1fb359a560d2c5ff7722c to your computer and use it in GitHub Desktop.
Save carlynorama/a60ffd752ee1fb359a560d2c5ff7722c to your computer and use it in GitHub Desktop.
Green-Red-White LED Pattern for Tree
//See https://github.com/s-marley/FastLED-basics/blob/main/3.%20Palettes/blueGradientPal/blueGradientPal.ino
#include <FastLED.h>
#define NUM_LEDS 200
#define LED_PIN 10
CRGB leds[NUM_LEDS];
//uint8_t paletteIndex = 0;
uint8_t colorIndex[NUM_LEDS];
DEFINE_GRADIENT_PALETTE( christmas_gp ) {
0, 255, 0, 0,
100, 255, 200, 50,
126, 0, 255, 0,
191, 255, 200, 50,
220, 255, 0, 0,
255, 255, 0, 0,
};
CRGBPalette16 myPal = christmas_gp;
void setup() {
FastLED.addLeds<WS2812B, LED_PIN, RGB>(leds, NUM_LEDS);
FastLED.setBrightness(20);
for (int i = 0; i < NUM_LEDS; i++) {
colorIndex[i] = random8();
}
}
void loop() {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = ColorFromPalette(myPal, colorIndex[i]);
}
EVERY_N_MILLISECONDS(20) {
for (int i = 0; i < NUM_LEDS; i++) {
colorIndex[i]++;
}
}
// fadeToBlackBy(leds, NUM_LEDS, 1);
FastLED.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment