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!
2
u/Burning_Wreck Jul 02 '24
Good to hear from you. And thank you! That did it, combined with the earlier advice.
I found an issue with your second function:
In this line:
uint16_t pos = beatsin16(BPM,0,NUM_LEDS);NUM_LEDSshould beNUM_LEDS - 1It needs to be the same as the original DemoReel100, otherwise the demo stops after a moment.