d333gs

WHITE GLITTER

Sep 27th, 2020
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include "FastLED.h"
  2.  
  3. #define LEDPIN 6
  4. #define LED_TYPE NEOPIXEL
  5. #define NUM_LEDS 512
  6. #define BRIGHTNESS 100
  7. #define FRAMES_PER_SECOND 12
  8. CRGB leds[NUM_LEDS];
  9.  
  10.  
  11. void setup() {
  12. //sanity delay
  13. delay(3000);
  14.  
  15. // set up LED strip info
  16. FastLED.addLeds<LED_TYPE,LEDPIN>(leds,NUM_LEDS).setCorrection(TypicalLEDStrip);
  17. FastLED.setBrightness(BRIGHTNESS);
  18. }
  19.  
  20.  
  21. void loop() {
  22. //changing the third variable changes how quickly the lights fade
  23. fadeLightBy( leds, NUM_LEDS, 1);
  24.  
  25. //changing this variable will increase the chance of a "star" popping up
  26. addGlitter(450);
  27.  
  28.  
  29. FastLED.show();
  30.  
  31. }
  32.  
  33.  
  34. //glitter effect
  35. void addGlitter( fract8 chanceOfGlitter) {
  36. if( random8() < chanceOfGlitter) {
  37. leds[ random16(NUM_LEDS) ] += CRGB::White;}
  38. }
Advertisement
Add Comment
Please, Sign In to add comment