
int button = 8;     
int led = 2;
int counter = 0;

void setup() {
  pinMode(led, OUTPUT);      
  pinMode(button, INPUT);     
}

void loop(){

  if (digitalRead(button) == HIGH) { 
    counter=500;
    digitalWrite(led, HIGH); 
  }
  if (counter>0){
    counter--;
    delay(10);  
  }
  else{
    digitalWrite(led, LOW); 
  }
}
