<?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>
									Arduino LED Effects and PIR - Arduino				            </title>
            <link>https://www.tweaking4all.com/forum/arduino/arduino-led-effects-and-pir/</link>
            <description>Tweaking4All.com Discussion Board</description>
            <language>en-US</language>
            <lastBuildDate>Sun, 10 May 2026 02:13:39 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: Arduino LED Effects and PIR</title>
                        <link>https://www.tweaking4all.com/forum/arduino/arduino-led-effects-and-pir/#post-3481</link>
                        <pubDate>Mon, 17 May 2021 10:08:38 +0000</pubDate>
                        <description><![CDATA[Cool - let me know if you run into a problem or not 😊]]></description>
                        <content:encoded><![CDATA[<p>Cool - let me know if you run into a problem or not 😊 </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/arduino-led-effects-and-pir/#post-3481</guid>
                    </item>
				                    <item>
                        <title>RE: Arduino LED Effects and PIR</title>
                        <link>https://www.tweaking4all.com/forum/arduino/arduino-led-effects-and-pir/#post-3476</link>
                        <pubDate>Sun, 16 May 2021 18:58:57 +0000</pubDate>
                        <description><![CDATA[@hans Thank you for your help and time. 
I get the codes you shared on the effects post and try to change them such as meteor rain up and down and PIR sensors etc. Did not write them myself...]]></description>
                        <content:encoded><![CDATA[<p>@hans Thank you for your help and time. </p>
<p>I get the codes you shared on the effects post and try to change them such as meteor rain up and down and PIR sensors etc. Did not write them myself since my knowledge about coding is limited, just copied them from another projects that is close to what I want. </p>
<p>If you see something that is odd, it's probably my mistake not intended, but the code I posted seems to be working without any issues (or I haven't noticed any mulfunction yet) just slow on long strips.</p>
<p>About the PIR states, I have one at the bottom of the stairs and another at the top. (I wrote "alttan cikan and üstten inen to find out which one is which meaning walking up or down) So their codes teorically should be the same, just inverse. I haven't noticed the lack of usage for PIR state2   🙄 </p>
<p>I'll try the codes that you edited for me in a short time and see if it works as planned.</p>
<p>Thanks again appriciate it.</p>]]></content:encoded>
						                            <category domain="https://www.tweaking4all.com/forum/arduino/">Arduino</category>                        <dc:creator>Anonymous</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/arduino-led-effects-and-pir/#post-3476</guid>
                    </item>
				                    <item>
                        <title>RE: Arduino LED Effects and PIR</title>
                        <link>https://www.tweaking4all.com/forum/arduino/arduino-led-effects-and-pir/#post-3471</link>
                        <pubDate>Sun, 16 May 2021 13:54:32 +0000</pubDate>
                        <description><![CDATA[Well, first thing we should do is move to FastLED ... I did this quickly based on your code.So ... this is most likely not the final answer to your question, but it will get us there eventua...]]></description>
                        <content:encoded><![CDATA[<p>Well, first thing we should do is move to FastLED ... I did this quickly based on your code.<br />So ... this is most likely not the final answer to your question, but it will get us there eventually 😊 </p>
<p><em><strong>Note</strong></em>: I wasn't able to test, since I do not have the hardware laying around, but it compiles without errors.</p>
<p>Cleaned up formatting and migrated to FastLED:</p>
<pre contenteditable="false">#define FASTLED_INTERNAL       // just used to mute the Pragma messages when compiling
#include "FastLED.h"
#define PIN 2
#define NUM_LEDS 425
CRGB leds;

int inputPin = 7;              // choose the input pin (for PIR sensor1)
int inputPin2 = 4;             // choose the input pin (for PIR sensor2)
int pirState = LOW;            // we start, assuming no motion detected
int pirState2 = LOW;           // we start, assuming no motion detected2
int val = 0;                   // variable for reading the pin status
 
void setup() {
  FastLED.addLeds&lt;WS2811, PIN, GRB&gt;(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  
  FastLED.clear();  // clear all pixel data
  FastLED.show();
  
  pinMode(inputPin, INPUT);     // declare sensor as input
  pinMode(inputPin2, INPUT);     // declare sensor as input
 
  Serial.begin(9600);
}
 
void loop(){
  if (digitalRead(inputPin) == HIGH) {   // alttan çıkan kontolü
    Serial.println("alttan cikan!");
    
    meteorRain(0xB7,0x00,0xFE,5, 64, true, 0);
    colorWipe(0xFF,0xB1,0x6E, 10);
    delay(1000);
    colorWipe(0x00,0x00,0x00, 10);// wipe led off
    
    if (pirState == LOW) {  // we have just turned on
      Serial.println("alttan cikan");  // We only want to print on the output change, not state
      pirState = HIGH;
    } 
  }
 
  if (digitalRead(inputPin2) == HIGH) {
    Serial.println("üstten inen!");
    
    meteorRaindown(0xFF,0x00,0x00,5, 64, true, 0);
    colorWipedown(0xFF,0xB1,0x6E, 10);
    delay(1000);
    colorWipedown(0x00,0x00,0x00, 10);// wipe led off
    
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("üstten inen");
      // We only want to print on the output change, not state
      pirState = HIGH;
    } 
  }
}

void meteorRain(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) {  
  FastLED.clear();
 
  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);
  }
}

void meteorRaindown(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) {  
  FastLED.clear();
 
  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); // &lt;-- change here
      } 
    }
   
    FastLED.show();
    delay(SpeedDelay);
  }
}

void colorWipe(byte red, byte green, byte blue, int SpeedDelay) {
  for(uint16_t i=0; i&lt;NUM_LEDS; i++) {
      leds = CRGB(red, green, blue);
      FastLED.show();
      delay(SpeedDelay);
  }
}
void colorWipedown(byte red, byte green, byte blue, int SpeedDelay) {
  for(uint16_t i=NUM_LEDS; i &lt; -1; i--) {
      leds = CRGB(red, green, blue);
      FastLED.show();
      delay(SpeedDelay);
  }
}

</pre>
<p> </p>
<p>Next thing I noticed is that your <strong>void loop()</strong> is a little bit mixed up it seems.</p>
<p>You defined 2 variables for the PIR states, but for example "pirState" has a value assigned and you set it to HIGH at some point, but never back to LOW or anything like that. I suspect this was intended to store the PIR state of the first PIR. Likewise the variable pirState2 was defined but never used. It is a little confusing what is going on there.</p>
<p>Maybe you're looking for something like this, which is just a wild guess, since I wasn't able to test this.</p>
<pre contenteditable="false">void loop(){
  pirState = digitalRead(inputPin);
  
  if (pirState == HIGH) {   // alttan çıkan kontolü
    Serial.println("alttan cikan!");
    
    meteorRain(0xB7,0x00,0xFE,5, 64, true, 0);
    colorWipe(0xFF,0xB1,0x6E, 10);
    delay(1000);
    colorWipe(0x00,0x00,0x00, 10);// wipe led off
  }

  pirState2 = digitalRead(inputPin2);
  
  if (pirState2 == HIGH) {
    Serial.println("üstten inen!");
    
    meteorRaindown(0xFF,0x00,0x00,5, 64, true, 0);
    colorWipedown(0xFF,0xB1,0x6E, 10);
    delay(1000);
    colorWipedown(0x00,0x00,0x00, 10);// wipe led off
  }
}</pre>
<p> </p>
<p>Note: I do realize that during testing and tinkering, code can become a little messy. <br />When things do not quite work as expected, it is always a good idea to clean up and format code, so it becomes more readable. 😊 </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/arduino-led-effects-and-pir/#post-3471</guid>
                    </item>
				                    <item>
                        <title>Arduino LED Effects and PIR</title>
                        <link>https://www.tweaking4all.com/forum/arduino/arduino-led-effects-and-pir/#post-3470</link>
                        <pubDate>Sun, 16 May 2021 13:20:16 +0000</pubDate>
                        <description><![CDATA[From a comment under the Arduino LED Effects article:
Question:
When PIR sensor activates first meteor rain climbs, and colorwipe follows it when done. The problem is meteor rain performs ...]]></description>
                        <content:encoded><![CDATA[<p>From a <a href="https://www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/#comment-545952" target="true">comment</a> under the Arduino LED Effects article:</p>
<p>Question:</p>
<p>When PIR sensor activates first meteor rain climbs, and colorwipe follows it when done. The problem is meteor rain performs very slow on long strips even tough I set the setting fastest. It works fine for 2m led, but when I connect 7 meters it really slows down. Also the delay time between meteor rain and colorwipe increases when 7m led stip is connected, while it is acceptable with 2 meters.</p>
<p>Is there a way to make the meteor rain really fast with 7m led strip and reduce the delay between two effects? </p>
<p>Bonus question: Is it possible to combine colorwipe effect to be leaded by meteor rain effect? I mean 2nd effect kicks in before the 1st one is finished. So the beginning of the colorwipe looks like meteor rain. </p>
<p> </p>
<p>Code:</p>
<p>Omg, I have been trying to make the corrections that you suggested for few days but couldn't make it work :( I attached the code I use, if you have time can you please edit it?</p>
<pre contenteditable="false">#include &lt;Adafruit_NeoPixel.h&gt;
#define PIN 2
#define NUM_LEDS 425
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);

 
int ledPin = 2;                // choose the pin for the LED
int inputPin = 7;               // choose the input pin (for PIR sensor1)
int inputPin2 = 4;               // choose the input pin (for PIR sensor2)
int pirState = LOW;             // we start, assuming no motion detected
int pirState2 = LOW;            // we start, assuming no motion detected2
int val = 0;                    // variable for reading the pin status
 
void setup() {
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare sensor as input
  pinMode(inputPin2, INPUT);     // declare sensor as input
 
  Serial.begin(9600);
}
 
void loop(){
  if (digitalRead(inputPin) == HIGH) {   // alttan çıkan kontolü
    Serial.println("alttan cikan!");
    meteorRain(0xB7,0x00,0xFE,5, 64, true, 0);
    colorWipe(0xFF,0xB1,0x6E, 10);
    delay(1000);
    colorWipe(0x00,0x00,0x00, 10);// wipe led off
    if (pirState == LOW) {  // we have just turned on
      Serial.println("alttan cikan");  // We only want to print on the output change, not state
      pirState = HIGH;
    } 
  }
 
  if (digitalRead(inputPin2) == HIGH) {
    Serial.println("üstten inen!");
    meteorRaindown(0xFF,0x00,0x00,5, 64, true, 0);
    colorWipedown(0xFF,0xB1,0x6E, 10);
    delay(1000);
    colorWipedown(0x00,0x00,0x00, 10);// wipe led off
    if (pirState == LOW) {
      // we have just turned on
      Serial.println("üstten inen");
      // We only want to print on the output change, not state
      pirState = HIGH;
    } 
  }
}
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 meteorRaindown(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(NUM_LEDS-i-j, red, green, blue); // &lt;-- change here
  } 
}
   
    showStrip();
    delay(SpeedDelay);
  }
}

void colorWipe(byte red, byte green, byte blue, int SpeedDelay) {
  for(uint16_t i=0; i&lt;NUM_LEDS; i++) {
      setPixel(i, red, green, blue);
      showStrip();
      delay(SpeedDelay);
  }
}
void colorWipedown(byte red, byte green, byte blue, int SpeedDelay) {
  for(uint16_t i=NUM_LEDS; i &lt; -1; i--) {
      setPixel(i, 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  
}

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>Hans</dc:creator>
                        <guid isPermaLink="true">https://www.tweaking4all.com/forum/arduino/arduino-led-effects-and-pir/#post-3470</guid>
                    </item>
							        </channel>
        </rss>
		