#include <TimerOne.h>

int ledou[] = {4, 5, 6};
int ledlr[] = {8, 9, 10};

static bool wechsel = true;

const byte interruptPin = 7;

int state1 = 0;
int state2 = 0;

void setup() {
  for (int i = 0; i < 3; i++) {
    pinMode(ledou[i], HIGH);
    pinMode(ledlr[i], HIGH);
  }

  Timer1.initialize(1000000);
  Timer1.attachInterrupt(schaltung);
}

void loop() {

}

void schaltung() {
  if (wechsel) {
    switch (state1) {
      case 0:
        reset();
        wechsel = !wechsel;
        digitalWrite(ledou[0], HIGH);
        state1 = 1;
        break;

      case 1:
        reset();
        digitalWrite(ledou[0], HIGH);
        digitalWrite(ledou[1], HIGH);
        state1 = 2;
        break;

      case 2:
        reset();
        digitalWrite(ledou[2], HIGH);
        pause();
        state1 = 3;
        break;

      case 3:
        pauseReset();
        reset();
        digitalWrite(ledou[1], HIGH);
        state1 = 0;
        break;
    }
  } else {
    switch (state2) {
      case 0:
        reset();
        wechsel = !wechsel;
        digitalWrite(ledlr[0], HIGH);
        state2 = 1;
        break;

      case 1:
        reset();
        digitalWrite(ledlr[0], HIGH);
        digitalWrite(ledlr[1], HIGH);
        state2 = 2;
        break;

      case 2:
        reset();
        digitalWrite(ledlr[2], HIGH);
        pause();

        state2 = 3;
        break;

      case 3:
        pauseReset();
        reset();
        digitalWrite(ledlr[1], HIGH);
        state2 = 0;
        break;
    }
  }
}

void reset() {
  const int* led;
  if (wechsel) {
    for (int i = 0; i < 3; i++) {
      digitalWrite(ledou[i], LOW);
    }
  } else {
    for (int i = 0; i < 3; i++) {
      digitalWrite(ledlr[i], LOW);
    }
  }
}

void test() {
  for (int i = 0; i < 3; i++) {
    digitalWrite(ledou[i], LOW);
  }
}

void pauseReset() {
  Timer1.detachInterrupt();
  Timer1.initialize(1000000);
  Timer1.attachInterrupt(schaltung);
}

void pause() {
  long sec = 5 * 1000000;
  Timer1.detachInterrupt();
  Timer1.initialize(sec);
  Timer1.attachInterrupt(schaltung);
}