#include <TimerOne.h>
static bool wechsel = true;
int state1 = 0;
int state2 = 0;
unsigned long previousMillis = 0;
const unsigned long interval = 5000;
int timerState = 0;
void setup() {
DDRD = 0x70; // Set PD4, PD5, PD6 as output
DDRB = 0x07; // Set PB0, PB1, PB2 as output
Timer1.initialize(1000000); // Set timer period to 1 second
Timer1.attachInterrupt(schaltung);
}
void loop() {
}
void schaltung() {
if (wechsel) {
switch (state1) {
case 0:
wechsel = !wechsel;
PORTD = (1 << PD4);
state1 = 1;
break;
case 1:
PORTD = (1 << PD4) | (1 << PD5);
state1 = 2;
break;
case 2:
PORTD = (1 << PD6);
state1 = 3;
break;
case 3:
PORTD = (1 << PD5);
state1 = 0;
break;
}
} else {
switch (state2) {
case 0:
wechsel = !wechsel;
PORTB = (1 << PB0);
state2 = 1;
break;
case 1:
PORTB = (1 << PB0) | (1 << PB1);
state2 = 2;
break;
case 2:
PORTB = (1 << PB2);
state2 = 3;
break;
case 3:
PORTB = (1 << PB1);
state2 = 0;
break;
}
}
}