Hello, I'm currently working on a Raindrop animation for my 20x24 LED matrix.

Hello, I’m currently working on a Raindrop animation for my 20x24 LED matrix. I have successfully been able to drop a single raindrop down the matrix but have ran into problems trying to get multiple raindrops to fall down the matrix. The code that i have written will place a single raindrop onto the matrix and have it fall at a random speed. What i would like to do is have it so that there are many raindrops on the screen at once.

Here is a link to my code:

Should also note that I have been using this YouTube video as a basic trouble shooting guide. This guys has a ton of cool videos that have helped me with some of the problem solving for this animation.

Check out @Jeremy_Williams Matrix code. Might be similar to what you’re looking to do.
https://plus.google.com/+JeremyWilliams1/posts/7BvwZFdxj1m

https://plus.google.com/+JeremyWilliams1/posts/7BvwZFdxj1m

Seems like the answer is right there inthe video but whatever.

I suggest you set up some arrays, each of the size that is how many drops you want. SO, an array for the y position, another array for the x position, and one for the speed, you could also have one for the color, and another for how long the tail is for each drop. The following is based on your code , you should be able to cut and paste from this back into your structure.

//Globals
int howmany = 10; //10 drops
int x[10] , y [10] , yspeed[10], tail[10], color[10];

void setup()
{
//!!!
//your code for setting up the matrix was here, put it back!!!
//!!!

for ( byte i = 0; i < howmany; i++) { //set up all the drops with initial values
x[i] = random (MATRIX_WIDTH);
y[i] = -random(40, 20); //starting point
yspeed[i] = random(1, 5);
tail[i] = random(2, 5);// soomething new, now long is the tail…
color[i]= random8();// another new thing, pick a color for the drop too…
}
}

void loop() {
Show();
FastLED.delay(40);
FastLED.clear();
}

void Show() {
for (byte i= 0 ;i < howmany; i++) {
y[i] = y[i] + yspeed[i]; //y position = current value of y + the random speed variable
if (y[i] > MATRIX_HEIGHT + tail[i]) { //If the y value plus the tail exceeds the height of the matrix, then give y a new value
y[i] = random(-40, -20);
x[i] = random (MATRIX_WIDTH);
yspeed[i] = random(1, 5);
tail[i]= random(2,5);
}
else
// leds.DrawLine(x[i] , y[i] , x[i] , y[i] +tail[i], CRGB::Purple); //Draw a line from (x0, y0) to (x0, y0+2) The y+tail will make the raindrop tail pixels tall
leds.DrawLine(x[i] , y[i] , x[i] , y[i] +tail[i], CHSV(color[i], 255, 255)); //or do it with each drop having a new color
}
}

( @Mark_Estes Best to use http://gist.github.com to share code so G+ doesn’t wack the formatting.)

Thank you, just tried it out and it is looking awesome

@Reed_Jeandell i added a mutant variant of the above to my big matrix code and it is getting close to what I wanted (with a few tweaks).

Another technique is to draw falling single spots then instead of blanking the pixel next loop do a fade by a small value on every pixel every loop so you get trails as a side effect and don’t have to use more memory and code for them. leds[i].nscale8(245); is a good start, then tweak the scale factor to get a desirable fade length.

fade effect done in a similar manner to devicer’s recommendo.

missing/deleted image from Google+

@Mark_Estes That looks fabulous. :slight_smile:

@Mark_Estes Looking good :slight_smile: Could you share the latest code? I’d like to try it on the hat I’m building…

Animation: https://www.youtube.com/watch?v=7VH_mzjnUwE

Code: http://coto.p7.de/thunderstorm.ino

@Jeremy_Spencer https://app.box.com/s/xq52eaucp98pe0o0tix3ar5rsdv93xjd

sorry for the delay, I was out of town.

@Mark_Estes Thank you :slight_smile: