Created
August 10, 2018 01:24
Star
You must be signed in to star a gist
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 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