Skip to content

Instantly share code, notes, and snippets.

@carlynorama
Last active January 8, 2021 23:19
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/45b55d72212b2da800172ed4d391f8ec to your computer and use it in GitHub Desktop.
Save carlynorama/45b55d72212b2da800172ed4d391f8ec to your computer and use it in GitHub Desktop.
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