Skip to content

Instantly share code, notes, and snippets.

@focalintent
Created August 20, 2015 03:17
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 focalintent/064d517982656d68b326 to your computer and use it in GitHub Desktop.
Save focalintent/064d517982656d68b326 to your computer and use it in GitHub Desktop.
#include<FastLED.h>
#define NUM_LEDS 178
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<WS2811,7,GRB>(leds, NUM_LEDS);
// do the initial setup of leds
fill_solid(leds, NUM_LEDS, CRGB(32,0,32));
}
void loop() {
// fade any currently high leds
for(int i = 0; i < NUM_LEDS; i++) {
if(leds[i].r > 32) { leds[i].r--; }
if(leds[i].b > 32) { leds[i].b--; }
}
// pick a random led and make it high
int nPicked = random16() % NUM_LEDS;
leds[nPicked] = CRGB(64,0,64);
// show the leds
FastLED.show();
// delay for a little bit - this means it'll take roughly 1 second for leds to fade from (64,0,64) back to (32,0,32)
delay(30);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment