Last active
August 1, 2021 22:39
-
-
Save mock-turtle/d59716ab96dca6c8ec0b to your computer and use it in GitHub Desktop.
Using the glitter effect from the fastLED demo reel
This file contains hidden or 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 LEDPIN 6 | |
#define LED_TYPE NEOPIXEL | |
#define NUM_LEDS 15 | |
#define BRIGHTNESS 60 | |
#define FRAMES_PER_SECOND 120 | |
CRGB leds[NUM_LEDS]; | |
void setup() { | |
//sanity delay | |
delay(3000); | |
// set up LED strip info | |
FastLED.addLeds<LED_TYPE,LEDPIN>(leds,NUM_LEDS).setCorrection(TypicalLEDStrip); | |
FastLED.setBrightness(BRIGHTNESS); | |
} | |
void loop() { | |
//changing the third variable changes how quickly the lights fade | |
fadeToBlackBy( leds, NUM_LEDS, 10); | |
//changing this variable will increase the chance of a "star" popping up | |
addGlitter(30); | |
FastLED.show(); | |
} | |
//glitter effect | |
void addGlitter( fract8 chanceOfGlitter) { | |
if( random8() < chanceOfGlitter) { | |
leds[ random16(NUM_LEDS) ] += CRGB::White;} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment