#include <TimerOne.h>
static int ledou[] = {4,5,6};
static int ledlr[] = {8,9,10};
static bool wechsel = true;
int state = 0;
void setup(){
for(int i = 0; i < 3; i++){
pinMode(ledou[i], OUTPUT);
}
Timer1.initialize(1000000);
Timer1.attachInterrupt(schaltung);
}
void loop(){
}
void schaltung(){
const int* ampel;
if(wechsel){
ampel = ledou;
} else {
ampel = ledlr;
}
switch(state){
case 0:
wechsel = !wechsel;
digitalWrite(ampel[0], HIGH);
digitalWrite(ampel[1], LOW);
digitalWrite(ampel[2], LOW);
state = 1;
break;
case 1:
digitalWrite(ampel[0], HIGH);
digitalWrite(ampel[1], HIGH);
digitalWrite(ampel[2], LOW);
state = 2;
break;
case 2:
digitalWrite(ampel[0], LOW);
digitalWrite(ampel[1], LOW);
digitalWrite(ampel[2], HIGH);
state = 3;
break;
case 3:
digitalWrite(ampel[0], LOW);
digitalWrite(ampel[1], HIGH);
digitalWrite(ampel[2], LOW);
state = 0;
break;
}
}