<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Sharing a Meteor Rain effects sketch - Arduino				            </title>
            <link>https://www.tweaking4all.com/forum/arduino/sharing-a-meteor-rain-effects-sketch/</link>
            <description>Tweaking4All.com Discussion Board</description>
            <language>en-US</language>
            <lastBuildDate>Tue, 21 Jul 2026 00:44:33 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: Sharing a Meteor Rain effects sketch</title>
                        <link>https://www.tweaking4all.com/forum/arduino/sharing-a-meteor-rain-effects-sketch/#post-4037</link>
                        <pubDate>Tue, 15 Mar 2022 09:57:57 +0000</pubDate>
                        <description><![CDATA[Hi Kip!
Thank you so much for sharing, it is always cool and appreciated to see the work of others 👍 
Take a sketch and leave a sketch - interesting idea! I like it.I am however afraid tha...]]></description>
                        <content:encoded><![CDATA[<p>Hi Kip!</p>
<p>Thank you so much for sharing, it is always cool and appreciated to see the work of others 👍 </p>
<p>Take a sketch and leave a sketch - interesting idea! I like it.<br />I am however afraid that most will not leave a sketch.<br />If it is any indication of how things work: the LED Effects sketches have been downloaded more than 30,000 times - not even mentioning the folks that used copy and paste. From that maybe a handful of folks posted a comment and even less their sketches ...<br />But that's OK ... it is what it is and my purpose here is to share my experience(s) and hopefully help when I can ... 😉 <br />(still have to find time to look at your question from a month ago - OMG I cannot believe how fast time is going)</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/sharing-a-meteor-rain-effects-sketch/#post-4037</guid>
                    </item>
				                    <item>
                        <title>Sharing a Meteor Rain effects sketch</title>
                        <link>https://www.tweaking4all.com/forum/arduino/sharing-a-meteor-rain-effects-sketch/#post-4036</link>
                        <pubDate>Tue, 15 Mar 2022 05:29:07 +0000</pubDate>
                        <description><![CDATA[I was inspired by the generous act of @lakerice sharing the sketch that he created and I thought I&#039;d share this Meteor Rain master effects sketch that I have collected. Of course @Hans get t...]]></description>
                        <content:encoded><![CDATA[<p>I was inspired by the generous act of <span>@lakerice sharing the sketch that he created and I thought I'd share this Meteor Rain master effects sketch that I have collected. Of course @Hans get the credit for sharing most of the sketches on this list! I've simply put the effects that he's shared plus some others that I have after playing around with the original code. The descriptions of the effects are in the sketch and the colors and other individual effects can be adjusted as needed. Enjoy! </span></p>
<p>PS - @Hans, maybe you should create a place on your site kind of like the "Take a penny, leave a penny" concept. "Take a sketch, leave a sketch"! 🤔 </p>
<pre contenteditable="false">#include "FastLED.h"
#define NUM_LEDS 300
CRGB leds;
#define PIN 9

void setup()
{
  FastLED.addLeds&lt;WS2811, PIN, GRB&gt;(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}

void loop() {
//(R,G,B, After the color, we can set the meteor size – the number of LEDs that represent the meteor, not counting the tail of the meteor. 
  //The 5th parameter sets how fast the meteor tail decays/ disappears. A larger number makes the tail short and/or disappear faster. 
  //Theoretically a value of 64 should reduce the brightness by 25% for each time the meteor gets drawn.
  //Since meteors are not perfect, I’ve added the 6th parameter to mimic some sorts of difference in debris by making the decay a little random.
  //If this value is set to “true” then some randomness is added to the rail. If you set the value to “false” then the tail will be very smooth.
  //Finally there is the last parameter, which basically indicates how much the drawing speed has to be delayed. 
  //A value of zero (0) means maximum speed. Any value above zero indicates how many milliseconds (1000 milliseconds in a second) the drawing will be delayed.)



 // meteorRain - Color (red, green, blue), meteor size, trail decay, random trail decay (true/false), speed delay
    meteorRain(210, 0, 50, 4, 64, true, 4);
    meteorRainReverse(250, 70, 0, 3, 85, true, 2);
    meteorRainInsideOut(0, 80, 200, 2, 50, false, 5);
    meteorRainOutsideIn(250, 80, 50, 10, 65, true, 4);
    meteorRainCB(CRGB(10,30,10), CRGB(0,11,226),5 ,50 ,true, 0);
    meteorRainReverseCB(CRGB(10,10,30), CRGB(235,50,0),3 ,30 ,false, 0);
    meteorRainTransition(80,0xff,0xff,10, 64, true, 5);
}
//Starts at lowest number LED and goes to highest
void meteorRain(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) {  
  setAll(0,0,0);
 
  for(int i = 0; i &lt; NUM_LEDS; i++) {
   
    // fade brightness all LEDs one step
    for(int j=0; j&lt;NUM_LEDS; j++) {
      if( (!meteorRandomDecay) || (random(10)&gt;5) ) {
        fadeToBlack(j, meteorTrailDecay );        
      }
    }
   
    // draw meteor
    for(int j = 0; j &lt; meteorSize; j++) {
      if( ( i-j &lt;NUM_LEDS) &amp;&amp; (i-j&gt;=0) ) {
        setPixel(i-j, red, green, blue);
      }
    }
   
    FastLED.show();
    delay(SpeedDelay);
  }
  
  }

//Starts at highest number LED and goes to lowest
void meteorRainReverse(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) {  
  setAll(0,0,0);
 
  for(int i = 0; i &lt; NUM_LEDS; i++) {
   
   
    // fade brightness all LEDs one step
    for(int j=0; j&lt;NUM_LEDS; j++) {
      if( (!meteorRandomDecay) || (random(10)&gt;5) ) {
        fadeToBlack(j, meteorTrailDecay );        
      }
      
    }
   
    // draw meteor
    for(int j = 0; j &lt; meteorSize; j++) {
      if( ( i-j &lt;NUM_LEDS) &amp;&amp; (i-j&gt;=0) ) {
        setPixel(NUM_LEDS-i-j, red, green, blue);
      }
    }
   
    FastLED.show();
    delay(SpeedDelay);
  } 
}

//Starts at ends and goes to middle
void meteorRainOutsideIn(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay)  {  
  setAll(0,0,0);
 
  for(int i = 0; i &lt; (NUM_LEDS)/2; i++) {
   
   
    // fade brightness all LEDs one step
    for(int j=0; j&lt;NUM_LEDS; j++) {
      if( (!meteorRandomDecay) || (random(10)&gt;5) ) {
        fadeToBlack(j, meteorTrailDecay );        
      } 
    }
    // draw meteor
    for(int j=0; j &lt; meteorSize; j++) {
      if( ( i-j &lt;NUM_LEDS) &amp;&amp; (i-j&gt;=0) ) {
        setPixel(i-j, red, green, blue);
        setPixel(NUM_LEDS-i-j, red, green, blue); //draw in reverse
      }
    }
   
  FastLED.show();
    delay(SpeedDelay);
  }
}

//Starts mid strip and goes to ends
void meteorRainInsideOut(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay)  {  
  setAll(0,0,0);
 
  for(int i = 150; i &lt; NUM_LEDS; i++) {
   
   
    // fade brightness all LEDs one step
    for(int j=0; j&lt;NUM_LEDS; j++) {
      if( (!meteorRandomDecay) || (random(10)&gt;5) ) {
        fadeToBlack(j, meteorTrailDecay );        
      }
      
    }
   
    // draw meteor
    for(int j =0; j &lt; meteorSize; j++) {
      if( ( i-j &lt;NUM_LEDS) &amp;&amp; (i-j&gt;=0) ) {
        setPixel(i-j, red, green, blue);
        setPixel(NUM_LEDS-i-j, red, green, blue);
      }
    }
   
  FastLED.show();
    delay(SpeedDelay);
  }
}

//Meteor Rain with a Colored Background
void meteorRainCB(CRGB ColorBackground, CRGB ColorMeteor, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay)
{
// set background color
fill_solid( leds, NUM_LEDS, ColorBackground );

for(int i = 0; i &lt; NUM_LEDS; i++)
{
// fade color to background color for all LEDs
for(int j=0; j &lt; NUM_LEDS; j++) {
if( (!meteorRandomDecay) || (random(10) &gt; 5) ) {
leds = fadeTowardColor(leds, ColorBackground, meteorTrailDecay );
}
}

// draw meteor
for(int j = 0; j &lt; meteorSize; j++) {
if( ( i-j &lt; NUM_LEDS) &amp;&amp; (i-j &gt;= 0) ) {
leds= ColorMeteor;
}
}

FastLED.show();
delay(SpeedDelay);
}
}

// Reversed Meteor Rain with a Colored Background
void meteorRainReverseCB(CRGB ColorBackground, CRGB ColorMeteor, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay)
{
// set background color
fill_solid( leds, NUM_LEDS, ColorBackground );

for(int i = 0; i &lt; NUM_LEDS; i++)
{
// fade color to background color for all LEDs
for(int j=0; j &lt; NUM_LEDS; j++) {
if( (!meteorRandomDecay) || (random(10) &gt; 5) ) {
leds = fadeTowardColor(leds, ColorBackground, meteorTrailDecay );
}
}

// draw meteor
for(int j = 0; j &lt; meteorSize; j++) {
if( ( i-j &lt; NUM_LEDS) &amp;&amp; (i-j &gt;= 0) ) {
leds= ColorMeteor;
}
}

FastLED.show();
delay(SpeedDelay);
}
}

// Functions from Kriegsman example
CRGB fadeTowardColor( CRGB&amp; cur, const CRGB&amp; target, uint8_t amount)
{
nblendU8TowardU8( cur.red, target.red, amount);
nblendU8TowardU8( cur.green, target.green, amount);
nblendU8TowardU8( cur.blue, target.blue, amount);
return cur;
}

// function used by "fadeTowardColor"
void nblendU8TowardU8( uint8_t&amp; cur, const uint8_t target, uint8_t amount)
{
if( cur == target) return;

if( cur &lt; target ) {
uint8_t delta = target - cur;
delta = scale8_video( delta, amount);
cur += delta;
} else {
uint8_t delta = cur - target;
delta = scale8_video( delta, amount);
cur -= delta;
}
}

//meteorRainTransition
void meteorRainTransition(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) { 
setAll(0,0,0);

for(int i = 0; i &lt; NUM_LEDS; i++) {

// fade brightness all LEDs one step
for(int j=0; j&lt;NUM_LEDS; j++) {
if( (!meteorRandomDecay) || (random(10)&gt;5) ) {
fadeToBlack(j, meteorTrailDecay ); 
}
}

// draw meteor
for(int j = 0; j &lt; meteorSize; j++) {
if( ( i-j &lt;NUM_LEDS) &amp;&amp; (i-j&gt;=0) ) {
setPixel(i-j, red, green, blue);
}
}

FastLED.show();
delay(SpeedDelay);
}
}

void fadeToBlack(int ledNo, byte fadeValue) {
  // FastLED
   leds.fadeToBlackBy( fadeValue ); 
}


void setPixel(int Pixel, byte red, byte green, byte blue) {
   // FastLED
   leds.r = red;
   leds.g = green;
   leds.b = blue;
}

void setAll(byte red, byte green, byte blue) {
  for(int i = 0; i &lt; NUM_LEDS; i++ ) {
    setPixel(i, red, green, blue);
  }
 FastLED.show();
}</pre>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>Kip</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/sharing-a-meteor-rain-effects-sketch/#post-4036</guid>
                    </item>
							        </channel>
        </rss>
		