Advertisement
atuline

Simple_circle.ino

Feb 10th, 2021 (edited)
1,150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. /* Simple FastLED circle
  2. *
  3. *
  4. */
  5.  
  6. #include <FastLED.h> // FastLED library.
  7.  
  8. #ifdef ESP8266
  9. #define FASTLED_ALLOW_INTERRUPTS 0 // Used for ESP8266 with WS2812 LED's. Ugh!!!
  10. #endif
  11.  
  12. // Fixed definitions cannot change on the fly.
  13. #define LED_DT D4 // Data pin to connect to the strip.
  14. #define COLOR_ORDER GRB // It's GRB for WS2812 and BGR for APA102.
  15. #define LED_TYPE WS2812
  16. #define NUM_LEDS 30 // Number of LED's.
  17.  
  18. uint8_t max_bright = 64; // Overall brightness definition. It can be changed on the fly.
  19.  
  20. struct CRGB leds[NUM_LEDS]; // Initialize our LED array.
  21.  
  22.  
  23. void setup() {
  24. LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS); // Use this for WS2812
  25. FastLED.setBrightness(max_bright);
  26. } // setup()
  27.  
  28.  
  29. void loop() {
  30. fadeToBlackBy(leds, NUM_LEDS, 4); // Smaller value = longer tail
  31. int i = (millis()/40) % NUM_LEDS; // How fast it goes.
  32. leds[i] = CRGB::White;
  33. FastLED.show();
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement