Skip to content

Instantly share code, notes, and snippets.

@kbostick88
Created August 10, 2018 01:24
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 kbostick88/dcc92c4a602143a0c10e04ca8869e7a8 to your computer and use it in GitHub Desktop.
Save kbostick88/dcc92c4a602143a0c10e04ca8869e7a8 to your computer and use it in GitHub Desktop.
#include <FastLED.h>
#define LED_PIN 7
#define NUM_LEDS 100
#define BRIGHTNESS 150
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
#define UPDATES_PER_SECOND 100
CRGBPalette16 currentPalette;
TBlendType currentBlending;
extern const TProgmemPalette16 myC9Palette_p PROGMEM;
void setup() {
delay( 3000 ); // power-up safety delay
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
currentPalette = myC9Palette_p;
currentBlending = NOBLEND;
}
void loop()
{
static uint8_t startIndex = 0;
startIndex = startIndex + 1; /* motion speed */
FillLEDsFromPaletteColors( startIndex);
FastLED.show();
FastLED.delay(1000 / UPDATES_PER_SECOND);
}
void FillLEDsFromPaletteColors( uint8_t colorIndex)
{
uint8_t brightness = 255;
for( int i = 0; i < NUM_LEDS; i++) {
leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
colorIndex += 3;
}
}
const TProgmemPalette16 myC9Palette_p PROGMEM =
{
CRGB::White,
CRGB::Red,
CRGB::Green,
CRGB::Yellow,
CRGB::Blue,
CRGB::Orange
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment