static bool pausen = false;
static bool wechsel = false;
void setup() {
DDRD |= 0x70;
DDRB |= 0x07;
PORTD = PORTB = 0;
}
void loop() {
schaltungGruen();
delay(2000);
schaltungRot();
}
void schaltungGruen() {
for (int i = 4; i < 7; i++) {
PORTD = (1 << i);
pause();
if(PIND & (1<<PD4)){
PORTD |= (1<<PD5);
pause();
i++;
}
}
pausen = true;
pause();
// wechsel = !wechsel;
}
void schaltungRot() {
for (int i = 6; i >= 4; i--) {
PORTD = (1 << i);
pause();
}
pausen = true;
pause();
}
void pause() {
int eins;
if (pausen) {
eins = 2000;
} else {
eins = 1000;
}
delay(eins);
pausen = false;
}