#include <FastLED.h>
#define NUM_STRIPS 4
#define LEDS_PER_STRIP 25
#define TOTAL_LEDS (NUM_STRIPS * LEDS_PER_STRIP)
#define DATA_LED_PIN 13
#define DATA_POTSPEED_PIN 12
#define DATA_POTLEN_PIN 14
CRGB leds[TOTAL_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_LED_PIN>(leds, TOTAL_LEDS);
pinMode(DATA_POTSPEED_PIN, INPUT);
pinMode(DATA_POTLEN_PIN, INPUT);
Serial.begin(115200);
Serial.println("Start");
}
void loop() {
int pot = map(analogRead(DATA_POTSPEED_PIN), 0, 4095, 100, 5); // Speed control
int len = map(analogRead(DATA_POTLEN_PIN), 0, 4095, 5, 50); // Length control
static int position = 0; // Static variable to keep track of position
updateLEDs(position, len); // Update LEDs in a continuous loop
position = (position + 1) % TOTAL_LEDS;
delay(pot); // Delay for smooth animation
}
void updateLEDs(int position, int len) {
// Calculate start and end points for the lit section with wrap-around
for (int i = 0; i < TOTAL_LEDS; i++) {
int distance = abs(i - position);
if (distance > TOTAL_LEDS / 2) {
distance = TOTAL_LEDS - distance; // Wrap around for continuous effect
}
if (distance <= len) {
byte fadeAmount = map(distance, 0, len, 0, 255); // Fade amount calculation
leds[i] = CRGB::Blue;
leds[i].fadeToBlackBy(fadeAmount);
} else {
leds[i] = CRGB::Black;
}
}
FastLED.show();
}
Fade Length
Light Speed