Guest User

Untitled

a guest
Dec 15th, 2025
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1.  
  2. #include "FastLED.h"
  3.  
  4. #define NUM_LEDS 100
  5. #define LED_DATA_PIN 3
  6. #define BRIGHTNESS 255 // low brightness for stability
  7. #define DELAY_MS 50 // controls speed of the wave
  8. #define TAIL_LENGTH 10 // length of the fading tail
  9.  
  10. CRGB leds[NUM_LEDS];
  11.  
  12. void setup() {
  13. FastLED.addLeds<WS2812B, LED_DATA_PIN, GRB>(leds, NUM_LEDS);
  14. FastLED.setBrightness(BRIGHTNESS);
  15. fill_solid(leds, NUM_LEDS, CRGB::Black);
  16. FastLED.show();
  17. }
  18.  
  19. void loop() {
  20. for (int head = 0; head < NUM_LEDS + TAIL_LENGTH; head++) {
  21. // First, fade all LEDs slightly to create a tail effect
  22. for (int i = 0; i < NUM_LEDS; i++) {
  23. leds[i].nscale8(200); // 200/255 β‰ˆ 78% brightness remaining
  24. }
  25.  
  26. // Light up the head LED in full red
  27. if (head < NUM_LEDS) {
  28. leds[head] = CRGB::Red;
  29. }
  30.  
  31. FastLED.show();
  32. delay(DELAY_MS);
  33. }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment