short butonpin = 3, role1 = 5, role2 =6, role3 = 7, role4 = 8, rolemode = 0;
void setup ()
{
Serial.begin(9600);
pinMode (butonpin , INPUT_PULLUP);
pinMode (role1 , OUTPUT);
pinMode (role2 , OUTPUT);
pinMode (role3 , OUTPUT);
pinMode (role4 , OUTPUT);
}
void loop()
{
if (!digitalRead(butonpin))
{delay(250);
if (rolemode<5)
{
rolemode++;
Serial.println(rolemode);
} else {
rolemode=0;
}
}
switch (rolemode) {
case 0:
digitalWrite(role1,0);
digitalWrite(role2,0);
digitalWrite(role3,0);
digitalWrite(role4,0);
Serial.println("case 0");
break;
case 1:
digitalWrite(role1,1);
digitalWrite(role2,0);
digitalWrite(role3,0);
digitalWrite(role4,0);
Serial.println("case 1");
break;
case 2:
digitalWrite(role1,1);
digitalWrite(role2,1);
digitalWrite(role3,0);
digitalWrite(role4,0);
Serial.println("case 2");
break;
case 3:
digitalWrite(role1,1);
digitalWrite(role2,1);
digitalWrite(role3,1);
digitalWrite(role4,0);
Serial.println("case 3");
break;
case 4:
digitalWrite(role1,1);
digitalWrite(role2,1);
digitalWrite(role3,1);
digitalWrite(role4,1);
delay(5000);
rolemode++;
Serial.println("case 4");
break;
case 5:
digitalWrite(role1,1);
digitalWrite(role2,1);
digitalWrite(role3,1);
digitalWrite(role4,0);
Serial.println("case 5");
break;
}
}