Created
April 18, 2017 10:29
-
-
Save Tejkaran/cd6c7b1c065d193d77788a9115956249 to your computer and use it in GitHub Desktop.
all preset color palettes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "FastLED.h" | |
#define NumPixels 51 // number of LEDs in strip - count starts at 0, not 1 | |
#define DataRate_Mhz 4 // how fast data refreshes at - [----CHECK THIS----] - slower rates are more successful when timing is not essential!!!!! | |
#define DataPin 11 // data pin | |
#define ClockPin 13 // clock Pin | |
CRGB leds[NumPixels]; | |
CRGBPalette16 currentPalette; | |
TBlendType currentBlending; | |
extern CRGBPalette16 myRedWhiteBluePalette; | |
extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM; | |
int startTimer; | |
int currentTimer; | |
int changeInterval = 20000 | |
uint8_t pattern = 0; | |
uint8_t i; | |
void setup() | |
{ | |
delay(1000); // saftey first | |
FastLED.addLeds<APA102,DataPin,ClockPin,BGR,DATA_RATE_MHZ(DataRate_Mhz)>(leds,NumPixels); | |
fill_solid(leds, NumPixels, CRGB(0,0,0)); // fill all black | |
FastLED.show(); // show | |
Serial.begin(115200); // monitor speed | |
currentBlending = LINEARBLEND; // options are LINEARBLEND or NOBLEND - linear is 'cleaner' | |
} | |
void loop() | |
{ | |
switch (pattern) //more info here: https://github.com/FastLED/FastLED/blob/master/colorpalettes.cpp | |
{ | |
case 0: currentPalette = LavaColors_p; break; // orange, red, black and yellow), | |
case 1: currentPalette = CloudColors_p; break; // blue and white | |
case 2: currentPalette = OceanColors_p; break; // blue, cyan and white | |
case 3: currentPalette = ForestColors_p; break; // greens and blues | |
case 4: currentPalette = RainbowColors_p; break; // standard rainbow animation | |
case 5: currentPalette = RainbowStripeColors_p; break; // single colour, black space, next colour and so forth | |
case 6: currentPalette = PartyColors_p; break; // red, yellow, orange, purple and blue | |
case 7: currentPalette = HeatColors_p; break; // red, orange, yellow and white | |
} | |
currentTimer = millis(); | |
if (currentTimer - startTimer >= changeInterval) | |
{ | |
startTimer = millis(); | |
if(pattern >7) | |
{pattern = 0;} | |
else | |
{++pattern;} | |
} | |
static uint8_t startIndex = 0; | |
startIndex = startIndex + 1; // motion speed - seems to get it 'moving' | |
FillLEDsFromPaletteColors(startIndex); | |
FastLED.show(); | |
FastLED.delay(25); | |
} | |
void FillLEDsFromPaletteColors(uint8_t colorIndex) | |
{ | |
uint8_t brightness = 10; | |
for(int i = 0; i < NumPixels; i++) | |
{ | |
leds[i] = ColorFromPalette(currentPalette, colorIndex, brightness, currentBlending); | |
colorIndex += 3; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment