const int buttonPin = 2;

const int ledPin1 = 11;
const int ledPin2 = 12;
const int ledPin3 = 13;

int buttonState = 0;

int direction = 1;

void setup() {
  pinMode(buttonPin, INPUT);

  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
}

void loop() {
  int buttonStatePrev = buttonState;
  buttonState = digitalRead(buttonPin);

  // only trigger change when button gets pressed 

  if (buttonState == HIGH) {
    if (buttonStatePrev == LOW) {
      direction *= -1;
    }

    digitalWrite(ledPin1, HIGH);
    digitalWrite(ledPin2, HIGH);
    digitalWrite(ledPin3, HIGH);
    delay(10);    
  } else {
    digitalWrite(ledPin1, LOW);
    digitalWrite(ledPin2, LOW);
    digitalWrite(ledPin3, LOW);

    if (direction == 1) {
      digitalWrite(ledPin3, LOW);
      digitalWrite(ledPin1, HIGH);
      delay(250);
      digitalWrite(ledPin1, LOW);
      digitalWrite(ledPin2, HIGH);
      delay(250);
      digitalWrite(ledPin2, LOW);
      digitalWrite(ledPin3, HIGH);
      delay(250);
    } else {
      digitalWrite(ledPin1, LOW);
      digitalWrite(ledPin3, HIGH);
      delay(250);
      digitalWrite(ledPin3, LOW);
      digitalWrite(ledPin2, HIGH);
      delay(250);
      digitalWrite(ledPin2, LOW);
      digitalWrite(ledPin1, HIGH);
      delay(250);
    }
  }
}
