Skip to content

Instantly share code, notes, and snippets.

@hsiboy
Last active August 25, 2017 16:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hsiboy/8eb2e9b16304e0e04fcf to your computer and use it in GitHub Desktop.
Save hsiboy/8eb2e9b16304e0e04fcf to your computer and use it in GitHub Desktop.
COD running light for Dave Windsor - FastLED
# video here https://www.youtube.com/watch?v=7Ir0bbCBXa8
#include <FastLED.h>
#if FASTLED_VERSION < 3001000
#error "Requires FastLED 3.1 or later; check github for latest code."
#endif
#define DATA_PIN 6
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
#define NUM_LEDS 32
#define BRIGHTNESS 96
CRGB leds[NUM_LEDS];
// an array of leds to light, in sequence order
int gRunningOrder[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,9,23,24,25,26,27,28,29,30,31,11,32,21};
// determine how many leds to light
int gNumLeds = sizeof(gRunningOrder)/sizeof(int);
void setup() {
delay(3000); // 3 second delay for recovery
// tell FastLED about the LED strip configuration
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
FastLED.clear();
FastLED.show();
}
void loop()
{
// Move a single dot along a strip
for(uint8_t ledNumber = 0; ledNumber < gNumLeds; ledNumber++)
{
// Turn our current led ON, then show the leds
leds[gRunningOrder[ledNumber]] = CRGB::Red;
// Show the leds (only one of which is has a color set, from above
// Show turns actually turns on the LEDs
FastLED.show();
// Wait a little bit - this will dictate speed
delay(30);
// this will leave a tail
fadeToBlackBy( leds, NUM_LEDS, 64);
//or un comment this to turn the leds off quickly, not leaving tail
//leds[gRunningOrder[ledNumber]] = CRGB::Black;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment