LED Strip - Loop too slow


I have created a sketch that lights up an LED strip by bringing down one dot (rain drop) at a time. It looks and works great until I increase the number of LEDs. My final project has around 185 LEDs. Raining down one dot at a time to light up LEDs is taking forever. I am looking to complete the whole effect within 3-5 seconds. Currently, it is taking minutes.

Is there a way I can start bringing multiple dots down before the first one has reached its destination? I am thinking somehow, I will need to have multiple inner loops running. For example, once a dot has travelled 10 LEDs, start bringing in the next one and so on.

Thank you.

void rainComeDown () {
  //Outer loop to turn and keep LEDs on
  for (int dot2 = 1; dot2 <= NUM_LEDS-2; dot2++) {

    //Inner loop to waterfall/rain dots
    for (int dot = NUM_LEDS-2; dot >= dot2; dot--) {

      leds[dot] = CRGB::Red;

      leds[dot] = CRGB::Black;
    leds[dot2] = CRGB::Blue;

Don't call show() after each change you make.

septillion: Don't call show() after each change you make.

I am calling show so that I can create the on-off effect for the dot to travel. Am I missing something?

Then I'm just not sure what the effect looks like now and with "to many" leds. Can you make a quick video? (Everybody has a smartphone an Youtube ;))

septillion: Then I'm just not sure what the effect looks like now and with "to many" leds. Can you make a quick video? (Everybody has a smartphone an Youtube ;))

Sure, I will make a video. Thanks.


I finally got around to make a video of it. It is available here: https://youtu.be/3o_qBog7H8s

This is the effect I am after. However bringing down one drop at a time is very slow to fill the strip. I thought about lighting up multiple LEDs at once when a drop comes down but that makes the effect very blocky (lighting up 10 LED blocks etc).

Thank you for any suggestions.



Anyone, any suggestions?


I suggest you explain what your problem is. I'm not understanding what 'too slow' means, or what it looks like. Is the video you posted your video? Is that what you want or is that not what you want? What do you want the strip to do? I think whatever you want to end up with, will just be a matter of using math to write the code. You seem to be thinking of it as 'one bit of code per raindrop' that needs to be repeated. You instead need to see the code as something for the whole strip.

For example, if you wanted to only turn on one LED for every 10 LEDs, how would you do that? Figure that out without issuing 18 separate commands (since you said your strip is 185 LEDs). If you've had high school math, this should be simple.

Thank you for your reply. The efect in the video is exactly what I wanted but the pooling of drops on the strip (after each drop comes down) was too slow. I have given up on that idea.

Unfortunately, I do not have that much experience in programming these so only doing these using for loops.

So, in words, you want a single drop/led coming down and once it crosses the "waterline" the "waterline" should rise by one? And you want it to be quicker?

I think this is pretty quick already. If you want it quicker I think you just need to skip some leds while dropping. So for example every second led or light two at a time. If you go fast you will not really notice.

Or time the refreshing completely separate from the animation and make it fixed in time. Aka, just refresh (call .show()) 10 times a second and do the animation part separate. This is easier but the Arduino will do calculations "for nothing" because they will not show at that moment.

Thing is, for every movement of the drop you need to refresh ALL leds. 185 leds results in 555 bytes of data or 4440 bits of info every refresh.

Another approach to speed up the "pooling" animation without speeding up the "droplets" would be to have multiple droplets in progress at once. To make it look better you could have a random interval between introducing droplets. Adjust that random interval to get a pooling speed you like. Let me know if that sounds like what you wanted and you want some help coding it.

What type of led strip do you have?