<?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>
									Marble-run on Fire - Arduino				            </title>
            <link>https://www.tweaking4all.com/forum/arduino/marble-run-on-fire/</link>
            <description>Tweaking4All.com Discussion Board</description>
            <language>en-US</language>
            <lastBuildDate>Thu, 12 Mar 2026 19:36:57 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: Marble-run on Fire</title>
                        <link>https://www.tweaking4all.com/forum/arduino/marble-run-on-fire/#post-3235</link>
                        <pubDate>Sat, 13 Mar 2021 11:14:11 +0000</pubDate>
                        <description><![CDATA[Awesome! Well, always feel free to ask questions here.We all were beginners at some point.
I have bookmark folders like that as well hahah.To later find out that I haven&#039;t even touched them...]]></description>
                        <content:encoded><![CDATA[<p>Awesome! Well, always feel free to ask questions here.<br />We all were beginners at some point.</p>
<p>I have bookmark folders like that as well hahah.<br />To later find out that I haven't even touched them years later 😉 </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/marble-run-on-fire/#post-3235</guid>
                    </item>
				                    <item>
                        <title>RE: Marble-run on Fire</title>
                        <link>https://www.tweaking4all.com/forum/arduino/marble-run-on-fire/#post-3234</link>
                        <pubDate>Sat, 13 Mar 2021 11:12:12 +0000</pubDate>
                        <description><![CDATA[@hans
Dear Hans!
I&#039;m so grateful! The code compiles without error. I&#039;ll check it out with the strip after lunch.
Thank you very much for the lightspeed response. Amazing! Thanks a lot.
L...]]></description>
                        <content:encoded><![CDATA[<p>@hans</p>
<p>Dear Hans!</p>
<p>I'm so grateful! The code compiles without error. I'll check it out with the strip after lunch.</p>
<p>Thank you very much for the lightspeed response. Amazing! Thanks a lot.</p>
<p>Learning to program an Arduino and finding out things is fun, although my bookmark folder looks like the catalogue of the national library meanwhile 😉 </p>
<p>Have a nice weekend,</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/marble-run-on-fire/#post-3234</guid>
                    </item>
				                    <item>
                        <title>RE: Marble-run on Fire</title>
                        <link>https://www.tweaking4all.com/forum/arduino/marble-run-on-fire/#post-3230</link>
                        <pubDate>Sat, 13 Mar 2021 09:54:37 +0000</pubDate>
                        <description><![CDATA[Hi Thomas,
No problem! 
Calling Sparkle vs SparkleTimes requires an different number of parameters.
Sparkle(byte red, byte green, byte blue, int SpeedDelay);

SparkleTimed(byte red, byt...]]></description>
                        <content:encoded><![CDATA[<p>Hi Thomas,</p>
<p>No problem! </p>
<p>Calling Sparkle vs SparkleTimes requires an different number of parameters.</p>
<pre contenteditable="false">Sparkle(byte red, byte green, byte blue, int SpeedDelay);

SparkleTimed(byte red, byte green, byte blue, int SpeedDelay, int Seconds);</pre>
<p> </p>
<p>So when calling Sparkle, we need to pass 4 numbers: red, green, blue and the delay in milliseconds.</p>
<p>When calling SparkleTime, we need to pass 5 numbers: red, green, blue, delay in milliseconds, and seconds (how long the effect should run).</p>
<p>So in your code:</p>
<pre contenteditable="false">  if (analogValue &lt; threshold) {
    digitalWrite(ledPin1, HIGH);
    SparkleTimed(0xff, 0xff, 0xff, 0, 5); // added "5" to make the sparkles run 5 seconds
  } else {
    digitalWrite(ledPin1, LOW);
  } </pre>
<p> </p>
<p>This is a good experience though, since you'll get more familiar with possible error messages.<br />It basically says the same thing:</p>
<pre contenteditable="false">too few arguments to function 'void SparkleTimed(byte, byte, byte, int, int)'</pre>
<p>Or in other words: you're missing at least one value, in this case that last "int" number.</p>
<p>Hope this helps 😊 </p>
<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/marble-run-on-fire/#post-3230</guid>
                    </item>
				                    <item>
                        <title>RE: Marble-run on Fire</title>
                        <link>https://www.tweaking4all.com/forum/arduino/marble-run-on-fire/#post-3228</link>
                        <pubDate>Fri, 12 Mar 2021 21:19:32 +0000</pubDate>
                        <description><![CDATA[Now my story is continued:
As the FIRE effect runs so pretty well, I wanted to use your recommendation about the time function with the SPARKLE effect.
So the LDR is triggered, the Strip s...]]></description>
                        <content:encoded><![CDATA[<p>Now my story is continued:</p>
<p>As the FIRE effect runs so pretty well, I wanted to use your recommendation about the time function with the SPARKLE effect.</p>
<p>So the LDR is triggered, the Strip sparkles for 10 seconds, the strip shuts off and can be triggered again.</p>
<p>Unfortunately I'm not able to get the code running. The compiler always gives the error message:</p>
<p>"too few arguments to function 'void SparkleTimed(byte, byte, byte, int, int)"</p>
<p>I tried the alternatives, which are still in the code but it didn't work.</p>
<p>Even after reading your tutorial about functions (Which, by the way, is superb!!!) I'm still clueless! 😣 </p>
<p>Your assistance would be appreciated a lot.</p>
<p>Here is my code:</p>
<pre contenteditable="false">/* LDR triggered LED Strip with WS2812B and LED effect "SPARKLE" (by Hans)
 *  1.03.2021
 */

#define FASTLED_INTERNAL // just used to mute the Pragma messages when compiling
#include "FastLED.h"

#define NUM_LEDS 99
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 = 800; // 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 );
  // initialize the LED pin as an output:
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
}

// *** REPLACE FROM HERE ***

void loop() {
  // read the value of the ldr:
  int analogValue = analogRead(analogPin);

  // if the analog value is high enough, turn on the LED2(yellow):
  if (analogValue &gt; threshold) {
    digitalWrite(ledPin2, HIGH);
  } else {
    digitalWrite(ledPin2, LOW);
  }

  // if the analog value is low enough, turn on the LED1green:
  if (analogValue &lt; threshold) {
    digitalWrite(ledPin1, HIGH);
    SparkleTimed(0xff, 0xff, 0xff, 0);
//     SparkleTimed();
//    SparkleTimed(byte red, byte green, byte blue, int SpeedDelay, int Seconds) //          runs SPARKLE if LDR is triggered
//  SparkleTimed(0xff, 0xff, 0xff, 0, byte red, byte green, byte blue, int SpeedDelay, int Seconds);

  } else {
    digitalWrite(ledPin1, LOW);
  } 

  delay(1); // delay in between reads for stability
}

void SparkleTimed(byte red, byte green, byte blue, int SpeedDelay, int Seconds) {
  unsigned long startTime = millis();
  unsigned long runMillis = 1000 * Seconds;

  while (millis() - startTime &lt; runMillis) {
    Sparkle(red, green, blue, SpeedDelay);
  }
  fill_solid( leds, NUM_LEDS, CRGB(0,0,0));
  // fill_solid( leds, NUM_LEDS, CRGB::Black);
      FastLED.show();
}

void Sparkle(byte red, byte green, byte blue, int SpeedDelay) {
  int Pixel = random(NUM_LEDS);
  setPixel(Pixel,red,green,blue);
  showStrip();
  delay(SpeedDelay);
  setPixel(Pixel,0,0,0);
}
// *** 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>
<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/marble-run-on-fire/#post-3228</guid>
                    </item>
				                    <item>
                        <title>RE: Marble-run on Fire</title>
                        <link>https://www.tweaking4all.com/forum/arduino/marble-run-on-fire/#post-3138</link>
                        <pubDate>Tue, 23 Feb 2021 11:03:03 +0000</pubDate>
                        <description><![CDATA[Awesome!!!! 👍 😎 
Glad to hear it works as you wanted to! Nice!
And ... you&#039;re most welcome! Being able to help someone like this just makes my day 😊]]></description>
                        <content:encoded><![CDATA[<p>Awesome!!!! 👍 😎 </p>
<p>Glad to hear it works as you wanted to! Nice!</p>
<p>And ... you're most welcome! Being able to help someone like this just makes my day 😊 </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/marble-run-on-fire/#post-3138</guid>
                    </item>
				                    <item>
                        <title>RE: Marble-run on Fire</title>
                        <link>https://www.tweaking4all.com/forum/arduino/marble-run-on-fire/#post-3137</link>
                        <pubDate>Mon, 22 Feb 2021 22:27:13 +0000</pubDate>
                        <description><![CDATA[Hi Hans!
There&#039;s a big HEUREKA!!!
This line was just missing:
FastLED.show();
Now the sketch runs perfectly and I&#039;m so glad!
Thanks to your help. Without you I would never have made it.]]></description>
                        <content:encoded><![CDATA[<p>Hi Hans!</p>
<p>There's a big HEUREKA!!!</p>
<p>This line was just missing:</p>
<p>FastLED.show();</p>
<p>Now the sketch runs perfectly and I'm so glad!</p>
<p>Thanks to your help. Without you I would never have made it.</p>
<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/marble-run-on-fire/#post-3137</guid>
                    </item>
				                    <item>
                        <title>RE: Marble-run on Fire</title>
                        <link>https://www.tweaking4all.com/forum/arduino/marble-run-on-fire/#post-3136</link>
                        <pubDate>Mon, 22 Feb 2021 19:30:42 +0000</pubDate>
                        <description><![CDATA[@hans
Dear Hans!
Again: Thanks for your help!
I have put the codeline in the void FireTimed... exactly at the place you suggested. But the strip still gets stuck.
I double checked if I d...]]></description>
                        <content:encoded><![CDATA[<p>@hans</p>
<p>Dear Hans!</p>
<p>Again: Thanks for your help!</p>
<p>I have put the codeline in the void FireTimed... exactly at the place you suggested. But the strip still gets stuck.</p>
<p>I double checked if I did it like you suggested.</p>
<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/marble-run-on-fire/#post-3136</guid>
                    </item>
				                    <item>
                        <title>RE: Marble-run on Fire</title>
                        <link>https://www.tweaking4all.com/forum/arduino/marble-run-on-fire/#post-3135</link>
                        <pubDate>Mon, 22 Feb 2021 17:09:30 +0000</pubDate>
                        <description><![CDATA[Hi Thomas!
You&#039;re very welcome 😊 
To make the LEDs black after the 10 seconds, you can use
fill_solid( leds, NUM_LEDS, CRGB(0,0,0));
Like so:
void FireTimed(int Cooling, int Sparking, i...]]></description>
                        <content:encoded><![CDATA[<p>Hi Thomas!</p>
<p>You're very welcome 😊 </p>
<p>To make the LEDs black after the 10 seconds, you can use</p>
<p><strong>fill_solid( leds, NUM_LEDS, CRGB(0,0,0));</strong></p>
<p>Like so:</p>
<pre contenteditable="false">void FireTimed(int Cooling, int Sparking, int SpeedDelay, int Seconds) {
  unsigned long startTime = millis();
  unsigned long runMillis = 1000 * Seconds;

  while (millis() - startTime &lt; runMillis) {
    Fire(Cooling, Sparking, SpeedDelay);
  }
  
  fill_solid( leds, NUM_LEDS, CRGB(0,0,0));
}</pre>
<p> </p>
<p>This will set the entire strip to black (off).</p>
<p>Hope this fixes that little residue 😊 </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/marble-run-on-fire/#post-3135</guid>
                    </item>
				                    <item>
                        <title>RE: Marble-run on Fire</title>
                        <link>https://www.tweaking4all.com/forum/arduino/marble-run-on-fire/#post-3133</link>
                        <pubDate>Mon, 22 Feb 2021 13:04:03 +0000</pubDate>
                        <description><![CDATA[Hi Hans!
You are the man!!! I wasn´t expecting an answer that soon. Thank you VERY much!
I just checked the sketch out:
It compiles without errors and runs perfectly after triggering the ...]]></description>
                        <content:encoded><![CDATA[<p>Hi Hans!</p>
<p>You are the man!!! I wasn´t expecting an answer that soon. Thank you VERY much!</p>
<p>I just checked the sketch out:</p>
<p>It compiles without errors and runs perfectly after triggering the LDR.</p>
<p>The LDR can be triggered again after the 10 secs and it starts fine again. I´m very impressed!</p>
<p>There is just one small issue:</p>
<p>After the 10secs the Strip gets kind of stuck with some LEDs emitting white at the bottom and a few reds somewhere in the strip.</p>
<p>Maybe it´s neccessary to put all LEDs to low (or black) when the time has elapsed?</p>
<p>Your grateful</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/marble-run-on-fire/#post-3133</guid>
                    </item>
				                    <item>
                        <title>RE: Marble-run on Fire</title>
                        <link>https://www.tweaking4all.com/forum/arduino/marble-run-on-fire/#post-3131</link>
                        <pubDate>Mon, 22 Feb 2021 12:48:14 +0000</pubDate>
                        <description><![CDATA[Woops, forgot the triggering by other following marbles.
Since the Arduino is not made to multitask, we&#039;d need to check the LDR status in the while loop as well and act accordingly.Let&#039;s fi...]]></description>
                        <content:encoded><![CDATA[<p>Woops, forgot the triggering by other following marbles.</p>
<p>Since the Arduino is not made to multitask, we'd need to check the LDR status in the while loop as well and act accordingly.<br />Let's first test this new function and then look at how to work with the LDR's.</p>
<p>Since you're using FastLED, we can cleanup your code a little as well - which includes the new function, but is not yet considering following marbles;</p>
<pre contenteditable="false">/* LDR triggered LED Strip with WS2812B and LED effect "Fire" (by Hans)
 *  20.02.2021
 */

#define FASTLED_INTERNAL // just used to mute the Pragma messages when compiling
#include "FastLED.h"

#define NUM_LEDS 60
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 = 800; // 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);

  // initialize the LED pin as an output:
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
}

void loop() {
  // read the value of the ldr:
  int analogValue = analogRead(analogPin);

  // if the analog value is high enough, turn on the LED2yellow:
  if (analogValue &gt; threshold) {
    digitalWrite(ledPin2, HIGH);
  } else {
    digitalWrite(ledPin2, LOW);
  }

  // if the analog value is low enough, turn on the LED1green:
  if (analogValue &lt; threshold) {
    digitalWrite(ledPin1, HIGH);
    FireTimed(55, 120, 15, 10); //          ruft die Funktion FIRE auf, wenn LDR unterbrochen

  } else {
    digitalWrite(ledPin1, LOW);
  } //  könnte ich hier die Funktion für FIRE aufrufen?

  delay(1); // delay in between reads for stability
}

void FireTimed(int Cooling, int Sparking, int SpeedDelay, int Seconds) {
  unsigned long startTime = millis();
  unsigned long runMillis = 1000 * Seconds;

  while (millis() - startTime &lt; runMillis) {
    Fire(Cooling, Sparking, SpeedDelay);
  }
}

void Fire(int Cooling, int Sparking, int SpeedDelay) {
  static byte heat;
  int cooldown; {
    // Step 1.  Cool down every cell a little
    for (int i = 0; i &lt; NUM_LEDS; i++) {
      cooldown = random(0, ((Cooling * 10) / NUM_LEDS) + 2);

      if (cooldown &gt; heat) {
        heat = 0;
      } else {
        heat = heat - cooldown;
      }
    }

    // Step 2.  Heat from each cell drifts 'up' and diffuses a little
    for (int k = NUM_LEDS - 1; k &gt;= 2; k--) {
      heat = (heat + heat + heat) / 3;
    }

    // Step 3.  Randomly ignite new 'sparks' near the bottom
    if (random(255) &lt; Sparking) {
      int y = random(7);
      heat = heat + random(160, 255);
      //heat = random(160,255);
    }

    // Step 4.  Convert heat to LED colors
    for (int j = 0; j &lt; NUM_LEDS; j++) {
      setPixelHeatColor(j, heat);
    }

    FastLED.show();
    delay(SpeedDelay);
  }
}

void setPixelHeatColor(int Pixel, byte temperature) {
  // Scale 'heat' down from 0-255 to 0-191
  byte t192 = round((temperature / 255.0) * 191);

  // calculate ramp up from
  byte heatramp = t192 &amp; 0x3F; // 0..63
  heatramp &lt;&lt;= 2; // scale up to 0..252

  // figure out which third of the spectrum we're in:
  if (t192 &gt; 0x80) { // hottest
    leds = CRGB(255, 255, heatramp);
  } else if (t192 &gt; 0x40) { // middle
    leds = CRGB(255, heatramp, 0);
  } else { // coolest
    leds = CRGB(heatramp, 0, 0);
  }
}</pre>]]></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/marble-run-on-fire/#post-3131</guid>
                    </item>
							        </channel>
        </rss>
		