Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "FastLED.h"
- #define NUM_LEDS 100
- #define LED_DATA_PIN 3
- #define BRIGHTNESS 255 // low brightness for stability
- #define DELAY_MS 50 // controls speed of the wave
- #define TAIL_LENGTH 10 // length of the fading tail
- CRGB leds[NUM_LEDS];
- void setup() {
- FastLED.addLeds<WS2812B, LED_DATA_PIN, GRB>(leds, NUM_LEDS);
- FastLED.setBrightness(BRIGHTNESS);
- fill_solid(leds, NUM_LEDS, CRGB::Black);
- FastLED.show();
- }
- void loop() {
- for (int head = 0; head < NUM_LEDS + TAIL_LENGTH; head++) {
- // First, fade all LEDs slightly to create a tail effect
- for (int i = 0; i < NUM_LEDS; i++) {
- leds[i].nscale8(200); // 200/255 β 78% brightness remaining
- }
- // Light up the head LED in full red
- if (head < NUM_LEDS) {
- leds[head] = CRGB::Red;
- }
- FastLED.show();
- delay(DELAY_MS);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment