Leggere chiusura contatto 15 volte ogni due secondi

Rieccomi, ho fatto un po' di prove... Ho modificato il codice postato sopra da @PaoloP ma non sono riuscito ad ottenere quello che volevo...
Volevo, girando la solita rotella del telefono, dare una funzione ad ogni numero... se so che il numero uno si chiude per un tot di tempo, gli faccio fare una cosa.. e così via...
Il codice è il seguente:

// this constant won't change:
const int buttonPin = 8; // the pin that the pushbutton is attached to
const int ledPin = 12; // the pin that the LED is attached to

// Variables will change:
int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button
unsigned long t1, t2 = 0;
int durata = 0;
int intervallo=0;
int pippo=0;
void setup() {
// initialize the button pin as a input:
pinMode(buttonPin, INPUT);
// initialize the LED as an output:
pinMode(ledPin, OUTPUT);
// initialize serial communication:
Serial.begin(9600);
}


void loop() {
// read the pushbutton input pin:
buttonState = digitalRead(buttonPin);

// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
t2=millis();
durata=t2 - t1;
Serial.print(durata);
} 
else {
t1 = millis();
intervallo= t1 - t2;
Serial.print(" : ");
Serial.println(intervallo);
}
if (durata >5000)
{
pippo++;
}
if (pippo =1)
{
digitalWrite(ledPin, HIGH);
delay(100);
digitalWrite(ledPin, LOW); 
delay(100);
}
}
// save the current state as the last state, 
//for next time through the loop

}
Mi riuscite a dare una mano? Come posso fare? Esempi? Ancora grazie! :D