#define led1 4
#define led2 5
#define led3 6
#define sw1 2
#define sw2 3
#define sw3 8
boolean st1;
boolean st2;
boolean st3;
boolean st4;
boolean st5;
boolean st6;
byte  timer = 0;
byte cnt = 0;
byte cnt1 = 0;
byte x;
unsigned long interval = 2000;
unsigned long previousMillis = 0;
unsigned long currentMillis = 0;
/* ----------------------------------------------------- */
void setup() {
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);
  pinMode(sw1, INPUT);
  pinMode(sw2, INPUT);
  pinMode(sw3, INPUT);
  Serial.begin(9600);

}
/* ------------------------------------------------------ */
void loop() {
  /* ------------------------------------------------- */
  boolean SW1 = digitalRead(sw1);
  boolean SW2 = digitalRead(sw2);
  boolean SW3 = digitalRead(sw3);
//switch1
  if (SW1 == 0) {
    while (digitalRead(sw1) == 0) {
      delay(10);
    }
    cnt++; timer = 0; if (cnt > 3) {
      cnt = 3;
    }
  }

//switch2
  if (SW2 == 0) {
    while (digitalRead(sw2) == 0) {
      delay(10);
    }
    cnt--; timer = 0; if (cnt > 3) {
      cnt = 0;
    }
  }

  
  if (SW3 == 0&&timer == 20) {
    
      if((currentMillis - previousMillis)>= interval){
      st4=!st4;
      st5=!st5;
      st6=!st6;
      digitalWrite(led1, st4);
      digitalWrite(led2, st5);
      digitalWrite(led3, st6);
  previousMillis=millis();
}
previousMillis=0;
    }
 

  if(timer == 30){
    if (cnt == 1 && timer == 30){
      st1=!st1;
      digitalWrite(led1, st1);
      delay(200);
    }
    if (cnt == 2 && timer == 30){
      st2=!st2;
      digitalWrite(led2, st2);
      delay(200);
    }
    if(cnt == 3 && timer == 30 ){
        st3=!st3;
      digitalWrite(led3, st3);
      delay(200);
    }
      
    timer = 0;
    cnt = 0;
  }

currentMillis = millis(); 





  
    timer++;
    Serial.println("Timer:" + String(timer));
    Serial.println("cnt:" + String(cnt));
    delay(100);
  
}