Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Palette Display
#include <FastLED.h>
#define NUM_LEDS 200//41//16
#define LED_TYPE WS2812//WS2812
#define COLOR_ORDER RGB//GRB
#define DATA_PIN 10
//#define CLK_PIN 4
//#define VOLTS 5
//#define MAX_MA 1000
CRGB leds[NUM_LEDS];
uint8_t paletteIndex = 0;
CRGBPalette16 candlePalette = CRGBPalette16 (
0x020002,
0x020002,
0xc55f04,
0x9e4401,
0x431a02,
0x8f2208,
0x300000,
0x716710,
0xd22400,
0x881801,
0x874101,
0x885208,
0xFFCC33,
0xFFCC33,
0xCC2000,
0xEE3300
);
CRGBPalette16 myPalette = candlePalette; //other types of pallettes possible
int paletteLength = 16; //always 16 for CRGBPalette16
void setup() {
Serial.begin(9600);
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setBrightness(50);
FastLED.setCorrection(TypicalLEDStrip); //UncorrectedColor, TypicalLEDStrip, TypicalPixelString
delay(3000);
for(int r=0; r < (NUM_LEDS/paletteLength); r++) {
Serial.print("R: ");
Serial.println(r);
int led_offset = r*paletteLength;
Serial.println(led_offset);
for(int i=0; i < paletteLength; i++) {
int l = i + led_offset;
Serial.println(l);
leds[l] = myPalette[i];
}
}
FastLED.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment