#define Startx 2
#define Resetx 3
#define S1x 4
#define S2x 5
#define S3x 6
#define S4x 7
#define S5x A0
#define Q1 8
#define Q2 9
#define Q3 19
#define Q4 11
#define H 12
#define M 13
int schritt,startwert1,startwert2;
bool S1,S2,S3,S4,S5,Start,Reset;
void setup() {
Serial.begin(9600);
pinMode(Startx, INPUT_PULLUP);
pinMode(Resetx, INPUT_PULLUP);
pinMode(S1x, INPUT_PULLUP);
pinMode(S2x, INPUT_PULLUP);
pinMode(S3x, INPUT_PULLUP);
pinMode(S4x, INPUT_PULLUP);
pinMode(S5x, INPUT_PULLUP);
pinMode(Q1, OUTPUT);
pinMode(Q2, OUTPUT);
pinMode(Q3, OUTPUT);
pinMode(Q4, OUTPUT);
pinMode(H, OUTPUT);
pinMode(M, OUTPUT);
int schritt =0;
}
void loop() {
Start = !digitalRead(Startx);
Reset = !digitalRead(Resetx);
S1 = !digitalRead(S1x);
S2 = !digitalRead(S2x);
S3 = !digitalRead(S3x);
S4 = !digitalRead(S4x);
S5 = !digitalRead(S5x);
switch(schritt){
case 0: //Initialschritt
if (Start and !S4 and !S5){
schritt= 1;
break;
}
case 1: //
if (schritt == 1 &&S2){
schritt= 2;
break;
}
case 2: //
if (schritt == 2 && S3){
schritt= 3;
startwert1 = millis();
break;
}
case 3: //
if (schritt == 3 && millis()>startwert1+5000){
schritt= 4;
break;
}
case 4: //
if (schritt == 4 && S4){
schritt= 5;
startwert2 = millis();
break;
}
case 5: //
if (schritt == 5 && millis()>startwert2+5000){
schritt= 6;
break;
}
case 6: //
if (schritt == 6 &&S1){
schritt= 0;
break;
}
}
Serial.println(schritt);
//Serial.println(S3);
if (schritt ==1)
digitalWrite(Q1, HIGH);
else
digitalWrite(Q1, LOW);
if (schritt ==2){
digitalWrite(Q2, HIGH);
digitalWrite(M, HIGH);
}else
digitalWrite(Q2, LOW);
if (schritt ==4)
digitalWrite(H, HIGH);
else
digitalWrite(H, LOW);
if (schritt ==6){
digitalWrite(Q3, HIGH);
}else
digitalWrite(Q3, LOW);
if ((schritt ==4 or schritt ==5) and S5)
digitalWrite(Q4, HIGH);
else
digitalWrite(Q4, LOW);
if (schritt ==6 or schritt==0)
digitalWrite(M, LOW);
if (Reset)
schritt = 0;
}