I have a code that flashes a pattern with 5 lights when I press a switch. I would like to add a few more patterns that would happen the next few times the button is pressed. For example, have a code that has one pattern the first time it's pressed, have a different pattern the second time the button is pressed, and then have one more pattern the third time is pressed. The fourth time, I want the first pattern to occur again and the fifth time, the second pattern, and have this continue. What would I use in the code to achieve this? I'm new to Arduino and am just using this for an art class. Please help! Here is my code:
int switch1 = 0; //button
void setup() {
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(2, INPUT); //Switch
}
void loop() {
switch1 = digitalRead(2);
if(switch1 == LOW) {
// when button is not pressed:
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
}
else{
//when button is pressed:
delay(600);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
delay(600);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
delay(600);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
delay(600);
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
delay(2000);
digitalWrite(9, LOW);
}
}