Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.