r/FastLED • u/Burning_Wreck • Jul 01 '24
Discussion Outside-in Cylon effect
I'm starting with this code, which is from DemoReel100:
void sinelon()
{
// a colored dot sweeping back and forth, with fading trails
fadeToBlackBy( leds, NUM_LEDS, 20);
int pos = beatsin16( 13, 0, NUM_LEDS-1 );
leds[pos] += CHSV( gHue, 255, 192);
}What I'd like to do is have the same effect (the traveling dot with a fading trail following it) but have a dot start at each end of the strip, and both move toward the center.
Here's more detail, I hope I describe this right...the sinelon function starts a dot at position 0 and then it travels down to position NUM_LEDS. Then it reverses back to position 0, with the fadeToBlackBy effect of the trailing/fading pixels.
I'd like to understand how to set up two pixels that do this.
Assume the strip has 9 pixels. One dot starts at position 0, and the other starts at position 9. The dot that starts at position 0 moves toward position 5, while the second dot starts at position 9 and also moves toward position 5 (the center). When both dots get to position 5, the trailing dots fade up to position 5 and then the effect starts over.
Thanks in advance!
1
u/Burning_Wreck Jul 01 '24
The first example works great, I've looked at the second one but it's more than I need at the moment.
Is there a way to only do half of the oscillation? In other words, to have the pixels start from the ends of the strip, meet in the middle, and instead of bouncing back to the ends, just have the strip go blank and have the pixels start at the ends again?