LED sequence starting using 2 PIR sensors

Hello everybody! So what I want to do is turning on 10 LED one after another with a delay between them of 150 ms in one direction when one PIR sensor is active then turning them off in the same direction one after another when the same PIR sensor is off and do the same thing in the opposite direction when the second PIR sensor is active/inactive. I wrote the code and the LED´s light up and turn off fine in one direction but in the other direction when turning off it is in the opposite direction. I know that I am doing something wrong but I cannot figure it out what it is wrong.

int one=4;
int two=5;
int three=6;
int four=7;
int five=8;
int six=9;
int seven=10;
int eight=11;
int nine=12;
int ten=13;

int PIR1=2;
int PIR2=3;
int out1;
int out2;

void setup(){
  pinMode(one, OUTPUT);
  pinMode(two, OUTPUT);
  pinMode(three, OUTPUT);
  pinMode(four, OUTPUT);
  pinMode(five, OUTPUT);
  pinMode(six, OUTPUT);
  pinMode(seven, OUTPUT);
  pinMode(eight, OUTPUT);
  pinMode(nine, OUTPUT);
  pinMode(ten, OUTPUT);
  
  pinMode(PIR1, INPUT);
  pinMode(PIR2, INPUT);
  
  digitalWrite(one, LOW);
  digitalWrite(two, LOW);
  digitalWrite(three, LOW);
  digitalWrite(four, LOW);
  digitalWrite(five, LOW);
  digitalWrite(six, LOW);
  digitalWrite(seven, LOW);
  digitalWrite(eight, LOW);
  digitalWrite(nine, LOW);
  digitalWrite(ten, LOW);
}
  
  void loop() {
    out1=digitalRead(PIR1);
    out2=digitalRead(PIR2);
    
    
    if(out2==1) {
      leftrighton();
    }
    else if(out1==0) {
      leftrightoff();
    }
    else if(out1==1) {
      rightlefton();
    }
    else if(out2==0) {
      
      
      rightleftoff();
    }
  }
      
  void leftrighton() {
    
  digitalWrite(one, HIGH);
    delay(150);
  digitalWrite(two, HIGH);
    delay(150);
  digitalWrite(three, HIGH);
    delay(150);
  digitalWrite(four,HIGH);
    delay(150);
  digitalWrite(five, HIGH);
    delay(150);
  digitalWrite(six, HIGH);
    delay(150);
  digitalWrite(seven, HIGH);
    delay(150);
  digitalWrite(eight, HIGH);
    delay(150);
  digitalWrite(nine, HIGH);
    delay(150);
  digitalWrite(ten, HIGH);  
    
  }
    
    void leftrightoff() {
      
      
  digitalWrite(one, LOW);
     delay(150); 
  digitalWrite(two, LOW);
      delay(150);
  digitalWrite(three, LOW);
      delay(150);
  digitalWrite(four, LOW);
      delay(150);
  digitalWrite(five, LOW);
      delay(150);
  digitalWrite(six, LOW);
      delay(150);
  digitalWrite(seven, LOW);
      delay(150);
  digitalWrite(eight, LOW);
      delay(150);
  digitalWrite(nine, LOW);
      delay(150);
  digitalWrite(ten, LOW);
    
    }
    
    void rightlefton() {
      
      digitalWrite(ten, HIGH);
      delay(150);
      digitalWrite(nine, HIGH);
      delay(150);
      digitalWrite(eight, HIGH);
      delay(150);
      digitalWrite(seven, HIGH);
      delay(150);
      digitalWrite(six, HIGH);
      delay(150);
      digitalWrite(five, HIGH);
      delay(150);
      digitalWrite(four, HIGH);
      delay(150);
      digitalWrite(three, HIGH);
      delay(150);
      digitalWrite(two, HIGH);
      delay(150);
      digitalWrite(one, HIGH);
      
    }
    
    void rightleftoff() {
      
      digitalWrite(ten, LOW);
      delay(150);
      digitalWrite(nine, LOW);
      delay(150);
      digitalWrite(eight, LOW);
      delay(150);
      digitalWrite(seven,LOW);
      delay(150);
      digitalWrite(six, LOW);
      delay(150);
      digitalWrite(five, LOW);
      delay(150);
      digitalWrite(four, LOW);
      delay(150);
      digitalWrite(three,LOW);
      delay(150);
      digitalWrite(two, LOW);
      delay(150);
      digitalWrite(one, LOW);
    }

valydenta:
I know that I am doing something wrong but I cannot figure it out what it is wrong.

Using "delay()".

Less important, not using "for" loops, not using arrays. Using numerical names is a trifle tedious, doesn't help understanding the code.

Read, practice and understand this and/ or this. :grinning:

When out2 becomes zero while out1 is also zero, this piece of code:

else if (out1 == 0) {
    leftrightoff();
  }

is called before this part:

  else if (out2 == 0) {
    rightleftoff();
  }

which will probably always be the case!