<?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>
									Meteor Rain with LDR in a marble track - Arduino				            </title>
            <link>https://www.tweaking4all.com/forum/arduino/meteor-rain-with-ldr-in-a-marble-track/</link>
            <description>Tweaking4All.com Discussion Board</description>
            <language>en-US</language>
            <lastBuildDate>Thu, 12 Nov 2026 14:04:09 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: Meteor Rain with LDR in a marble track</title>
                        <link>https://www.tweaking4all.com/forum/arduino/meteor-rain-with-ldr-in-a-marble-track/#post-3913</link>
                        <pubDate>Sat, 22 Jan 2022 13:41:03 +0000</pubDate>
                        <description><![CDATA[Just posted the video here again (testing the forum)]]></description>
                        <content:encoded><![CDATA[250
<p>Just posted the video here again (testing the forum)</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/meteor-rain-with-ldr-in-a-marble-track/#post-3913</guid>
                    </item>
				                    <item>
                        <title>RE: Meteor Rain with LDR in a marble track</title>
                        <link>https://www.tweaking4all.com/forum/arduino/meteor-rain-with-ldr-in-a-marble-track/#post-3912</link>
                        <pubDate>Sat, 22 Jan 2022 13:40:11 +0000</pubDate>
                        <description><![CDATA[Awesome! Thank you Thomas for sharing!
Looks great  👍]]></description>
                        <content:encoded><![CDATA[<p>Awesome! Thank you Thomas for sharing!</p>
<p>Looks great  👍 </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/meteor-rain-with-ldr-in-a-marble-track/#post-3912</guid>
                    </item>
				                    <item>
                        <title>RE: Meteor Rain with LDR in a marble track</title>
                        <link>https://www.tweaking4all.com/forum/arduino/meteor-rain-with-ldr-in-a-marble-track/#post-3911</link>
                        <pubDate>Sat, 22 Jan 2022 12:53:38 +0000</pubDate>
                        <description><![CDATA[OOps!
Forgot the curcuit:
And a video of the working gizmo]]></description>
                        <content:encoded><![CDATA[<p>OOps!</p>
<p>Forgot the curcuit:</p>
<p>And a video of the working gizmo</p>
248
249
<p> </p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>ledmeup</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/meteor-rain-with-ldr-in-a-marble-track/#post-3911</guid>
                    </item>
				                    <item>
                        <title>RE: Meteor Rain with LDR in a marble track</title>
                        <link>https://www.tweaking4all.com/forum/arduino/meteor-rain-with-ldr-in-a-marble-track/#post-3910</link>
                        <pubDate>Sat, 22 Jan 2022 12:38:20 +0000</pubDate>
                        <description><![CDATA[Now here is a desciption of the gizmo I built up:
It is an element in my fischertechnik marble track. The ball triggers the LDR which starts the sketch on the NANO. Then the Meteor Rain run...]]></description>
                        <content:encoded><![CDATA[<p>Now here is a desciption of the gizmo I built up:</p>
<p>It is an element in my fischertechnik marble track. The ball triggers the LDR which starts the sketch on the NANO. Then the Meteor Rain runs 5 times and the module is ready for the next triggering.</p>
<p>Sounds simple? Well, the devil is in the details!</p>
<p>First you have to calibrate the LDR. Depending on the light emission of the LED used and the surrounding light, the resistance of the LDR differs.</p>
<p>So it has to be checked with the serial monitor using an analog output. Depending on that the threshold has to be defined. In this case it is 850.</p>
<p>For the lightbeams I use LEDs between 10000 and 20000 mcd in red. They usually work sufficient.</p>
<p>The green LED indicates the Ready Status of the circuit, the orange one indicates triggering. So if something is wrong you know where to check.</p>
<p>When you load the sketch to the Arduino <span style="color: #ff0000">DISCONNECT</span> the LED strip. Otherwise the Arduino tries to power the strip. With 105 LEDs the Arduino goes up in smoke!</p>
<p>Happy New Year!  😮 </p>
<p>And put a 1000uF capacitator between VCC and GND of the powersupply. It protects the strip.</p>
<p>Additionally the resistor for the dataline of the strip is neccessary. The values differ between 330 and 470. Both should be fine.</p>
<p>I split up the strip to create an impact area of 20 LEDs. That meant A LOT of soldering but it was worth it! Be sure to solder VERY preciselly for the soldering points on the</p>
<p>WS2812 are very tiny and lots of short circuits are at hand 🤐 </p>
<p>The code is not too complex. Anyway, I needed Hans´ help. Again. Thank you Hans. You are the man! 👍 </p>
<p>Any questions? Post ´em.</p>
<p>Have fun!</p>
<p>Thomas</p>
245
246
247
<pre contenteditable="false">/* LDR triggered LED Strip with WS2812B and LED effect "Meteor Rain" (Tweaking4All) */

#define FASTLED_INTERNAL  // just used to mute the Pragma messages when compiling
#include "FastLED.h"

#define NUM_LEDS 105
CRGB leds;
#define PIN 6

// Used Define since that does not take up any memory
#define analogPin A0     // LDR pin
#define ledPin1   12     // digital pin that the green LED is attached to
#define ledPin2   13     // digital pin that the yellow LED is attached to

#define threshold 850    // an arbitrary threshold level that's in the range of the analog input

void setup() {
  FastLED.addLeds &lt; WS2811, PIN, GRB &gt; (leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  fill_solid( leds, NUM_LEDS, CRGB(0,0,0));
  
  FastLED.show();
  
  // initialize the LED pins for output: 
  // Note: I picked 2 digital pins for this (#12 and #13) instead of the analog pins you used!
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  
  // LDR an PIN A0
  pinMode(analogPin, INPUT);

  // Initialize serial monitor/port
  Serial.begin(9600);
}


void loop() {

  // read the value of the ldr:
  int analogValue = analogRead(analogPin);
  
  // Did something pass the LDR (= dark?)
  if (analogValue &lt; threshold) {
    Serial.println("MARBLE PASSED LDR &lt;------");
    digitalWrite(ledPin1, LOW);
    digitalWrite(ledPin2, HIGH);

    // run meteor rain 5x
    for(int i=0; i&lt;5; i++) {
     //  meteorRain(0xff, 0xff, 0xff, 10, 50, true, 30);
      // colour RED:
     meteorRain(255, 48, 48, 10, 50, true, 30); 
     // hot pink
  //    meteorRain(255, 110, 180, 10, 50, true, 30);
    }
  } else {
    Serial.println("LDR Did not detect anything");
    digitalWrite(ledPin1, HIGH);
    digitalWrite(ledPin2, LOW);
    
    // All LEDs black
    fill_solid( leds, NUM_LEDS, CRGB(0,0,0));
    FastLED.show();
  }
  
  delay(50); // delay in between reads for stability
}

void meteorRain(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) {
  // All LEDs black
  fill_solid( leds, NUM_LEDS, CRGB(0,0,0));
  FastLED.show();

  for (int i = 0; i &lt; NUM_LEDS + NUM_LEDS; i++) {

    // fade brightness all LEDs one step
    for (int j = 0; j &lt; NUM_LEDS; j++) {
      if ((!meteorRandomDecay) || (random(10) &gt; 5)) {
        leds.fadeToBlackBy(meteorTrailDecay);
      }
    }

    // draw meteor
    for (int j = 0; j &lt; meteorSize; j++) {
      if ((i - j &lt; NUM_LEDS) &amp;&amp; (i - j &gt;= 0)) {
        leds = CRGB(red, green, blue);
      }
    }

    FastLED.show();
    delay(SpeedDelay);
  }
}</pre>
<p> </p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>ledmeup</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/meteor-rain-with-ldr-in-a-marble-track/#post-3910</guid>
                    </item>
				                    <item>
                        <title>RE: Meteor Rain with LDR in a marble track</title>
                        <link>https://www.tweaking4all.com/forum/arduino/meteor-rain-with-ldr-in-a-marble-track/#post-3904</link>
                        <pubDate>Fri, 21 Jan 2022 09:19:13 +0000</pubDate>
                        <description><![CDATA[Awesome Thomas! Glad to hear that. 😊 👍 
I&#039;m not sure where the &quot;=0&quot; is supposed to be placed (I need more coffee to wake up haha).Would you mind posting the full code - this way others may ...]]></description>
                        <content:encoded><![CDATA[<p>Awesome Thomas! Glad to hear that. 😊 👍 </p>
<p>I'm not sure where the "=0" is supposed to be placed (I need more coffee to wake up haha).<br />Would you mind posting the full code - this way others may benefit from it as well 😊 </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/meteor-rain-with-ldr-in-a-marble-track/#post-3904</guid>
                    </item>
				                    <item>
                        <title>RE: Meteor Rain with LDR in a marble track</title>
                        <link>https://www.tweaking4all.com/forum/arduino/meteor-rain-with-ldr-in-a-marble-track/#post-3903</link>
                        <pubDate>Thu, 20 Jan 2022 16:18:17 +0000</pubDate>
                        <description><![CDATA[Hi Hans!
I checked out your sketch. It works absolutely fine! Thank you very much.
There is just one little thing I corrected: in the void loop: =0 was missing, so i was undeclared.
But n...]]></description>
                        <content:encoded><![CDATA[<p>Hi Hans!</p>
<p>I checked out your sketch. It works absolutely fine! Thank you very much.</p>
<p>There is just one little thing I corrected: in the void loop: =0 was missing, so i was undeclared.</p>
<p>But never mind, you did a great job! (As always ;o)</p>
<p>👍</p>
<p>Have a nice day,</p>
<p>Thomas</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>ledmeup</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/meteor-rain-with-ldr-in-a-marble-track/#post-3903</guid>
                    </item>
				                    <item>
                        <title>RE: Meteor Rain with LDR in a marble track</title>
                        <link>https://www.tweaking4all.com/forum/arduino/meteor-rain-with-ldr-in-a-marble-track/#post-3891</link>
                        <pubDate>Sun, 16 Jan 2022 13:37:21 +0000</pubDate>
                        <description><![CDATA[Hi Thomas,
I made a few changes ... 

I used 2 digital pins for LED1 and LED2, instead of the Analog pins.
The meteor function is called 5 times with a for-loop in &quot;void loop()&quot;.
Change...]]></description>
                        <content:encoded><![CDATA[<p>Hi Thomas,</p>
<p>I made a few changes ... </p>
<ul>
<li>I used 2 digital pins for LED1 and LED2, instead of the Analog pins.</li>
<li>The meteor function is called 5 times with a for-loop in "void loop()".</li>
<li>Changed the analogPin and ledPIn1/2 to "#define" calls, so things take up less memory.</li>
<li>Reformatted the code a little for readability (always a good idea).</li>
<li>I optimized some code since you're using FastLED anyway ... 😊 </li>
</ul>
<p>The code below had NOT been tested, so things may not work as hoped for, since I do not have the hardware handy ... 😊 </p>
<p>Let me know how it worked ... </p>
<p>You stay healthy as well! 😉 </p>
<pre contenteditable="false">/* LDR triggered LED Strip with WS2812B and LED effect "Meteor Rain" (Tweaking4All) */

#define FASTLED_INTERNAL  // just used to mute the Pragma messages when compiling
#include "FastLED.h"

#define NUM_LEDS 105
CRGB leds;
#define PIN 6

// Used Define since that does not take up any memory
#define analogPin A0     // LDR pin
#define ledPin1   12     // digital pin that the green LED is attached to
#define ledPin2   13     // digital pin that the yellow LED is attached to

#define threshold 500    // an arbitrary threshold level that's in the range of the analog input

void setup() {
  FastLED.addLeds &lt; WS2811, PIN, GRB &gt; (leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  fill_solid( leds, NUM_LEDS, CRGB(0,0,0));
  FastLED.show();
  
  // initialize the LED pins for output: 
  // Note: I picked 2 digital pins for this (#12 and #13) instead of the analog pins you used!
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  
  // LDR an PIN A0
  pinMode(analogPin, INPUT);

  // Initialize serial monitor/port
  Serial.begin(9600);
}


void loop() {

  // read the value of the ldr:
  int analogValue = analogRead(analogPin);
  
  // Did something pass the LDR (= dark?)
  if (analogValue &lt; threshold) {
    Serial.println("MARBLE PASSED LDR &lt;------");
    digitalWrite(ledPin1, LOW);
    digitalWrite(ledPin2, HIGH);

    // run meteor rain 5x
    for(int i; i&lt;5; i++) {
      meteorRain(0xff, 0xff, 0xff, 10, 50, true, 30);
    }
  } else {
    Serial.println("LDR Did not detect anything");
    digitalWrite(ledPin1, HIGH);
    digitalWrite(ledPin2, LOW);
    
    // All LEDs black
    fill_solid( leds, NUM_LEDS, CRGB(0,0,0));
    FastLED.show();
  }
  
  delay(50); // delay in between reads for stability
}

void meteorRain(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) {
  // All LEDs black
  fill_solid( leds, NUM_LEDS, CRGB(0,0,0));
  FastLED.show();

  for (int i = 0; i &lt; NUM_LEDS + NUM_LEDS; i++) {

    // fade brightness all LEDs one step
    for (int j = 0; j &lt; NUM_LEDS; j++) {
      if ((!meteorRandomDecay) || (random(10) &gt; 5)) {
        leds.fadeToBlackBy(meteorTrailDecay);
      }
    }

    // draw meteor
    for (int j = 0; j &lt; meteorSize; j++) {
      if ((i - j &lt; NUM_LEDS) &amp;&amp; (i - j &gt;= 0)) {
        leds = CRGB(red, green, blue);
      }
    }

    FastLED.show();
    delay(SpeedDelay);
  }
}
</pre>
<p> </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/meteor-rain-with-ldr-in-a-marble-track/#post-3891</guid>
                    </item>
				                    <item>
                        <title>Meteor Rain with LDR in a marble track</title>
                        <link>https://www.tweaking4all.com/forum/arduino/meteor-rain-with-ldr-in-a-marble-track/#post-3890</link>
                        <pubDate>Sat, 15 Jan 2022 15:26:05 +0000</pubDate>
                        <description><![CDATA[Hi folks (and especially Hans)!
I want to add an LED strip with the Meteor Rain to my marble track.
The ball triggers an LDR which starts the sketch. It should run 5 times and then go back...]]></description>
                        <content:encoded><![CDATA[<p>Hi folks (and especially Hans)!</p>
<p>I want to add an LED strip with the Meteor Rain to my marble track.</p>
<p>The ball triggers an LDR which starts the sketch. It should run 5 times and then go back into a waiting status to be triggered again.</p>
<p>Thing is that Meteor Rain runs forever in my sketch and I can`t find the mistake.</p>
<p>I would be so greatful for help.</p>
<p>Stay healthy!</p>
<p>Thomas</p>
<p>Here is the sketch I did:</p>
<pre contenteditable="false">/* LDR triggered LED Strip with WS2812B and LED effect "Meteor Rain" (Tweaking 4 All)

 */

#define FASTLED_INTERNAL // just used to mute the Pragma messages when compiling
#include "FastLED.h"
#define NUM_LEDS 105
CRGB leds;
#define PIN 6
const int analogPin = A0; // pin that the sensor is attached to
const int ledPin1 = A2; // pin that the green LED is attached to
const int ledPin2 = A1; // pin that the yellow LED is attached to
const int threshold = 500; // an arbitrary threshold level that's in the range of the analog input
int ldrlows;                             //creates a variable integer called 'ldrlows'

void setup()
{
  FastLED.addLeds &lt; WS2811, PIN, GRB &gt; (leds, NUM_LEDS).setCorrection(TypicalLEDStrip );
  for (int i=0; i&lt;4; i++) meteorRain(0xff,0xff,0xff,10, 50, true, 30);
  // initialize the LED pin as an output:
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  // LDR an PIN A0
  pinMode (A0, INPUT);
   Serial.begin(9600);
}

// *** REPLACE FROM HERE ***

void loop() {
  
  // read the value of the ldr:
  int analogValue = analogRead(analogPin);
analogRead(A0); 
  // if the analog value is high enough, turn on the LED2(yellow):
  if (analogValue &gt; threshold) {
    digitalWrite(ledPin2, HIGH);
  } else {
    digitalWrite(ledPin2, LOW);
  }
if (analogValue &lt; threshold) {  //if the analog value of A0 is smaller than 800 then
    ldrlows = 1; //write ldrlows 1;
 }
  else {
 ldrlows = 0;
 }
  // print the analog value:
 Serial.println(ldrlows);
  // if the analog value is low enough, turn on the LED1green:
  if (analogValue &lt; threshold) {
    digitalWrite(ledPin1, HIGH);
    meteorRain(0xff,0xff,0xff,10, 50, true, 30);
  } else {
    digitalWrite(ledPin1, LOW);
  } 

  delay(50); // delay in between reads for stability
}

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+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);
      }
    }
   
    showStrip();
    delay(SpeedDelay);
  }
}

void fadeToBlack(int ledNo, byte fadeValue) {
 #ifdef ADAFRUIT_NEOPIXEL_H
    // NeoPixel
    uint32_t oldColor;
    uint8_t r, g, b;
    int value;
   
    oldColor = strip.getPixelColor(ledNo);
    r = (oldColor &amp; 0x00ff0000UL) &gt;&gt; 16;
    g = (oldColor &amp; 0x0000ff00UL) &gt;&gt; 8;
    b = (oldColor &amp; 0x000000ffUL);

    r=(r&lt;=10)? 0 : (int) r-(r*fadeValue/256);
    g=(g&lt;=10)? 0 : (int) g-(g*fadeValue/256);
    b=(b&lt;=10)? 0 : (int) b-(b*fadeValue/256);
   
    strip.setPixelColor(ledNo, r,g,b);
 #endif
 #ifndef ADAFRUIT_NEOPIXEL_H
   // FastLED
   leds.fadeToBlackBy( fadeValue );
 #endif  
}

// *** REPLACE TO HERE ***

void showStrip() {
 #ifdef ADAFRUIT_NEOPIXEL_H
   // NeoPixel
   strip.show();
 #endif
 #ifndef ADAFRUIT_NEOPIXEL_H
   // FastLED
   FastLED.show();
 #endif
}

void setPixel(int Pixel, byte red, byte green, byte blue) {
 #ifdef ADAFRUIT_NEOPIXEL_H
   // NeoPixel
   strip.setPixelColor(Pixel, strip.Color(red, green, blue));
 #endif
 #ifndef ADAFRUIT_NEOPIXEL_H
   // FastLED
   leds.r = red;
   leds.g = green;
   leds.b = blue;
 #endif
}

void setAll(byte red, byte green, byte blue) {
  for(int i = 0; i &lt; NUM_LEDS; i++ ) {
    setPixel(i, red, green, blue);
  }
  showStrip();
}</pre>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>ledmeup</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/meteor-rain-with-ldr-in-a-marble-track/#post-3890</guid>
                    </item>
							        </channel>
        </rss>
		