A helpful way to think about this is not in terms of the “things” you want to animate, but rather: where do you want light, and when?
For example: “I want an ever-lengthening steady bar of light slowly growing ‘up’ from one end of the strip, and also individual pixels lit up one at a time sequential from the OTHER end of the strip ‘moving’ toward the steady bar.”
In this case, it helps illustrate that there are probably TWO separate parts to your animation: the drips and the accumulated water puddle.
From there maybe it’s easier to start playing around with some code ideas…
Adding to @Mark_Kriegsman 's comment here, I would consider each drop as a certain volume of water that will either slowly of quickly accumulate in the bottom.
In this case, accumulating water just means increasing brightness of a pixel until it is full and then slowly filling up the next one on top.
A must here I think is the following antialiasing example (another fine sketch from Mark) that you should probably use for both the drop falling down and the water filling up !!!
Note that the example has 1/16th fractional pixels but you could make it as slow or as fast as you want your water to fill by changing the size that fraction for each drop.
Looking to the “demoReel100”, I’d like to understand and adapt the ‘sinelon’ animation. But I can’t see where the real code is.
My strip is 82 leds long.
My first goal would be to have a colored dot falling down with fading trails (like those in sinelon) from lead#81 to led #0.
Once done, I will repeat falling dots falling from #81 to #1, and so on until the last falling dots would be from #81 to #80.
Once this understood, I will study the proposed 2 animations for the same strip and will build an animation in the bottom part of my strip, showing the strip to be filled up with dropping dots.
This should not be too harsh for a start, but I don’t know where sinelon code is to understand it.
Thanks for your help.
Patrick
PS : once filled, the strip will be a rainbow background, where i will add a flashing light displaying the current temperature !
The sinelon code is astonishingly short. The animation code itself is just this:
void sinelon()
{
// a colored dot sweeping back and forth, with fading trails
fadeToBlackBy( leds, NUM_LEDS, 20);
int pos = beatsin16(13,0,NUM_LEDS);
leds[pos] += CHSV( gHue, 255, 192);
}
It does three things each time it is called, and each takes just one line above:
fade all of the existing pixel brightnesses a little bit. It does NOT erase it to black-- just fade everything a little.
determines a new position for a point that slides up and down the whole length of the LED strip (from 0 to NUM_LEDS), based on a sine wave pattern that repeats 13 times per minute. (I just picked 13 because it looked right. Try different numbers there!)
adds some colored light to one LED, the one at the position chosen in step 2. The hue of the light comes from gHue, a global variable that shifts slowly over time (elsewhere in the code).
And that’s it! Every loop it adds a little light to one LED, and fades all the others. And the position for which LED gets lit follows a sine wave at 13 BPM.
Try commenting out the line that fades the LEDs and see what happens. Or try changing it to fill_solid(0, NUM_LEDS, CRGB::Black), to clear out all the old light every time. Experiment with it a bit. Change the 13 to 33. Or to 3. Or 120. Play around until you get a feel for what’s doing what!
Oh- and that function is called repeatedly from the main loop, and after each time, the main loop also calls FastLED.show() to display the LEDs. But the animation itself is just those three lines.
Thanks Mark, I will try.
How to stop the animation when the last displayed dot reachs the bottom of the strip (pos(0)) ?
In other way, I only need to have falling drops.
For one-way falling drops, I don’t think you want a sine wave at all: those go down AND up.
Instead, just make the ‘pos’ go ‘down’ once per loop, and use an “if” statement to test if it’s hit the end. If so, reset it to the top again.
I can’t help any more on this this evening, but there are a ton of resources out there for simple computer animation: how to think frame-by-frame. I bet once you absorb some of that approach, you’ll find success here-- and I’m eager to see how it comes out!
this was also my conclusion, so I remove the sinewave.
May I suggest my code ?
The issue, I have is with the ‘length’ of the comet !! issue with FadeToBlack or ?
instead of sinelon() I wrote falling()
my led strip is 82 leds.