#define RED_1 13
#define GREEN_1 12
#define YELLOW_1 11
#define RED_2 10
#define GREEN_2 9
#define YELLOW_2 8
#define BUTTON 7
 int mode = 1;
 int buttonstate = 0;
 int lastbuttonstate = 0;
void setup() {
  // put your setup code here, to run once:
pinMode (RED_1, OUTPUT);
pinMode (GREEN_1, OUTPUT);
pinMode (YELLOW_1, OUTPUT);
pinMode (RED_2, OUTPUT);
pinMode (GREEN_2, OUTPUT);
pinMode (YELLOW_2, OUTPUT);
pinMode (BUTTON, INPUT);
Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:
 
buttonstate = digitalRead (BUTTON);

if(buttonstate != lastbuttonstate){
  
  if (buttonstate == 1){
   if (mode < 4){
       mode++;
     }
     else {
      mode = 1;
     } 
  Serial.print ("mode: ");
  Serial.println (mode);
  }
}
Serial.print (buttonstate);
delay (50);
lastbuttonstate = buttonstate;
if (buttonstate == 0){
switch (mode){
case 1 :
  digitalWrite(RED_1, HIGH);
  digitalWrite(RED_2, HIGH);
  digitalWrite(GREEN_1, LOW);
  digitalWrite(GREEN_2, LOW);
  digitalWrite(YELLOW_1, LOW);
  digitalWrite(YELLOW_2, LOW);
  delay (500);
  digitalWrite(RED_1, LOW);
  digitalWrite(RED_2, LOW);
  digitalWrite(GREEN_1, HIGH);
  digitalWrite(GREEN_2, HIGH);
  digitalWrite(YELLOW_1, LOW);
  digitalWrite(YELLOW_2, LOW);
  delay (500);
  digitalWrite(RED_1, LOW);
  digitalWrite(RED_2, LOW);
  digitalWrite(GREEN_1, LOW);
  digitalWrite(GREEN_2, LOW);
  digitalWrite(YELLOW_1, HIGH);
  digitalWrite(YELLOW_2, HIGH);
  delay (500);
  break;
case 2:
  digitalWrite(RED_1, HIGH);
  digitalWrite(RED_2, LOW);
  digitalWrite(GREEN_1, LOW);
  digitalWrite(GREEN_2, LOW);
  digitalWrite(YELLOW_1, LOW);
  digitalWrite(YELLOW_2, LOW);
  delay (200);
  digitalWrite(RED_1, LOW);
  digitalWrite(RED_2, LOW);
  digitalWrite(GREEN_1, HIGH);
  digitalWrite(GREEN_2, LOW);
  digitalWrite(YELLOW_1, LOW);
  digitalWrite(YELLOW_2, LOW);
  delay (200);
  digitalWrite(RED_1, LOW);
  digitalWrite(RED_2, LOW);
  digitalWrite(GREEN_1, LOW);
  digitalWrite(GREEN_2, LOW);
  digitalWrite(YELLOW_1, HIGH);
  digitalWrite(YELLOW_2, LOW);
  delay (200);
  break;
}
}
}