int pinLed[] = {6, 7, 8, 9, 10, 11, 12, 13};

void rtl() {
  for (int i = 0; i < 8; i++) {
    digitalWrite(pinLed[i], HIGH);
    delay(50);
    digitalWrite(pinLed[i], LOW);
    delay(50);
  }
}

void ltr() {
  for (int i = 7; i >= 0; i--) {
    digitalWrite(pinLed[i], HIGH);
    delay(50);
    digitalWrite(pinLed[i], LOW);
    delay(50);
  }
}

void setup() {
  for (int i = 0; i < 8; i++) {
    pinMode(pinLed[i], OUTPUT);
  }
}

void loop() {
  ltr();
  rtl();
}