#define led 7
#define sw 3
unsigned long interval = 2000;
unsigned long previousMillis = 0;
unsigned long currentMillis = 0;
boolean ledState = 0;
/*-------------------------------------*/
void setup() {
  Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(sw, INPUT);


}

void loop() {
 
 boolean Sw=digitalRead(sw);
if(Sw==0){
  currentMillis = millis(); 
}
else currentMillis=0;
if((currentMillis - previousMillis)>= interval){
  ledState = !ledState;
  digitalWrite(led,ledState);
  previousMillis=millis();
}
else previousMillis=0;
Serial.println(currentMillis);
}