I was advised on reddit forum which I link below, the following code to have a pattern travel across a led strip. On linked reddit tProcessing: tqrr4cccm6g71.mp4...
heres a video of the effect o I want to achive, and im attaching it to this post also.
As in the video i want this pattern to travel across in a repeating manner, so there would be the same patterns multiple instances simultaneously travelling across the strip. Can anyone help with this code?
It seems to be pos and sweeppos multiplying, depending on the number of leds on the strip, however i it to be a scalable solution since some strips have 60 and some have 300 leds.
#include <FastLED.h>
#define LED_PIN 10
#define NUM_LEDS 300
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
#define UPDATES_PER_SECOND 100
void setup() {
delay( 3000 ); // power-up safety delay
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, 120);
FastLED.setBrightness( BRIGHTNESS );
}
CRGBPalette16 sweep = CRGBPalette16(
CRGB::Blue,
CRGB::Green,
CRGB::Green,
CRGB::Green,
CRGB::Green,
CRGB::Green,
CRGB::Green,
CHSV( 90, 255, 255),
CHSV( 90, 255, 255),
CHSV( 90, 255, 255),
CRGB::Yellow,
CRGB::Yellow,
CRGB::Yellow,
CRGB::Yellow,
CRGB::Yellow,
CRGB::Yellow
);
const uint8_t SweepSize = 15;
const CRGB BackgroundColor = CRGB::Red;
for(int sweepPos = -SweepSize; sweepPos < NUM_LEDS; sweepPos++) {
fill_solid(leds, NUM_LEDS, BackgroundColor); // wasteful but easy
for(int i = 0; i < SweepSize; i++) {
int pos = i + sweepPos; if(pos > NUM_LEDS){ sweepPos = 0;}
if(pos < 0) continue; // not on the strip yet
leds[pos] = ColorFromPalette(sweep, (255 / SweepSize) * i);
// set color// past the end of the strip }
FastLED.show();
FastLED.delay(20);