Here’s a little drip animation I recently finished. @Ashley_M_Kirchner_No Thanks for the help with the variable delay code!
Too cool. And will this code be shared? 
That looks great!
I would also appreciate seeing the code if you are willing to share.
I don’t mind sharing how I figured this out:
Here is the line that calculates the amount of delay courtesy of Mr. Kirchner:
int variableDelay( int xVal, int x, int y){
xDelay = xVal - ((sqrt(((float)y - x)/y) - sqrt((y - x)/y)) * xVal);
return xDelay;
}
Here is the fall function, my LEDs are wired from the top down, that’s why I have to flipFlop:
void fall(){
for(x = NUM_LED; x > 0; x–){
flipFlop = (NUM_LED - x);
leds[flipFlop] = CHSV(hue, 255, (255 - (flipFlop * 2)));
variableDelay( 42, x, NUM_LED);
LEDS.show();
delay(xDelay);
leds[flipFlop] = CRGB::Black;
}
}
I then arranged everything into a switch case for easy control over the dropState:
switch(dropState){
case 1: swell(); dropState++; break;
case 2: fall(); dropState++; break;
case 3: bounce_and_fall(); dropState++; break;
case 4: bounce_and_fall_again(); dropState = 1; break;
}
And walla!
I tried to emulate this video I saw: http://www.youtube.com/watch?v=_wkTtAk2V_k
Except with a lower density LED strip like mine, the effect has its limits and doesn’t look as cool as this video.
Thanks Jon! I’m going to have to think for a bit about the delay function to understand how it works, but it’s still appreciated.
Here is another explanation of the delay function:
Specifically, this is the line that calculates the pause between each frame:
bouncePause = 85 - ((sqrt(((float)ceiling - currPx)/ceiling) - sqrt((ceiling - currPx)/ceiling)) * 85);
ceiling is a random variable determined for each shot going up. It determines how high it goes. currPx is the current pixel being worked on (along a string of 32), and the value ‘85’ just determines how fast it decays.
That helps a lot - thanks for the explanation.
That explanation is assuming two things, a) your strips are wired bottom-up, and b) you have pixels going up, decaying in speed, then coming back down.
It was written to simulate a firework being shot up then falling back. After it reaches the apex, I fade it out.
The flipFlop variable was my attempt at a “hack” to get around that fact. So far, out of all my tweaking, your equation has the most realistic looking “gravity” effect. Thanks!
I think it would be fun trying to use that for a fireworks effect. I think I’ll give it a go!
It looks great. I like how the drop hangs for a little bit before falling.
http://rurandom.org/justintime/index.php?title=Driving_the_WS2811_at_800_kHz_with_an_8_MHz_AVR
This is where I found the vid, I used his code as a rough template. I’m sure an advanced programmer can port his animation code over easier than I.
@Dave_Morgan
Go to about 3 minutes into this to see what it looks like in a bottom-up configuration: https://www.youtube.com/watch?v=aPkuTA6Jexo
Hai jon, can u share all other function code?
I did share the majority of the code, its up to you to put it together how “you” want. I can share how you can figure it out: Serial.print(). This is feature of the Arduino should be used as you develop and write your code. I used the serial monitor to give feedback on my calculations and algorithms. I highly suggest learning to use this feature of Arduino and adapt the code I have already shared.
