const int buttonPin = 2;     // select the input pin for the potentiometer
int ledPin = 13;      // select the pin for the LED
int sensorValue = 0;  // variable to store the value coming from the sensor
int buttonState = 0; 

int count = 0;
boolean now =false;
unsigned long times;

void setup() {
  // declare the ledPin as an OUTPUT:
   Serial.begin(115200);
   pinMode(buttonPin, INPUT);
   pinMode(ledPin, OUTPUT);
}

void loop() {
  

 buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    if (now==false){
      if (times ==0){
         times = millis();
         count += +1;
         Serial.println(count);
      } else {
        unsigned long delta;
        delta = millis() -times;
        if (delta >1000){
        count += +1;
         Serial.println(count);
          
        }
      }
     
      
      now=true;
    }
    digitalWrite(ledPin, LOW);
  } else {
    // turn LED off:
    now= false;
    times = 0;
    
    digitalWrite(ledPin, HIGH);
  }
}
