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 eventually 😊
Note: I wasn't able to test, since I do not have the hardware laying around, but it compiles without errors.
Cleaned up formatting and migrated to FastLED:
#define FASTLED_INTERNAL // just used to mute the Pragma messages when compiling
#include "FastLED.h"
#define PIN 2
#define NUM_LEDS 425
CRGB leds[NUM_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<WS2811, PIN, GRB>(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 < NUM_LEDS+NUM_LEDS; i++) {
// fade brightness all LEDs one step
for(int j=0; j<NUM_LEDS; j++) {
if( (!meteorRandomDecay) || (random(10)>5) ) {
leds[j].fadeToBlackBy( meteorTrailDecay );
}
}
// draw meteor
for(int j = 0; j < meteorSize; j++) {
if( ( i-j <NUM_LEDS) && (i-j>=0) ) {
leds[i-j] = 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 < NUM_LEDS+NUM_LEDS; i++) {
// fade brightness all LEDs one step
for(int j=0; j<NUM_LEDS; j++) {
if( (!meteorRandomDecay) || (random(10)>5) ) {
leds[j].fadeToBlackBy( meteorTrailDecay );
}
}
// draw meteor
for(int j = 0; j < meteorSize; j++) {
if( ( i-j <NUM_LEDS) && (i-j>=0) ) {
leds[NUM_LEDS-i-j]=CRGB(red, green, blue); // <-- change here
}
}
FastLED.show();
delay(SpeedDelay);
}
}
void colorWipe(byte red, byte green, byte blue, int SpeedDelay) {
for(uint16_t i=0; i<NUM_LEDS; i++) {
leds[i] = 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 < -1; i--) {
leds[i] = CRGB(red, green, blue);
FastLED.show();
delay(SpeedDelay);
}
}
Next thing I noticed is that your void loop() is a little bit mixed up it seems.
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.
Maybe you're looking for something like this, which is just a wild guess, since I wasn't able to test this.
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
}
}
Note: I do realize that during testing and tinkering, code can become a little messy.
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. 😊