arduino program not working properly

I have written one arduino program. According to my need, this program should print the value equal to time the switch has been touched. I am using simple switch, i.e just touching two metal plates to demonstrate the switch. I can't use commercially avialable switch in my project, since my project requres that switch botton has to be very easy to push with very little weight.
Here at every 1.5 second interval the arduino will save the number of push bottons and print that(for now), but it not working properly. Sometime it shows correct output, but sometime not. My program is:

unsigned long startTime, currentTime;

const int buttonPin = 2;
const int ledPin = 13;
int buttonState = 0;
int count = 0;
int low = 1; 
int t0 = 0; 

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  startTime = millis();
  pinMode(ledPin,OUTPUT);
  pinMode(buttonPin,INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  currentTime = millis();
  buttonState = digitalRead(buttonPin);
  
  if(buttonState == HIGH && currentTime-t0 > 200) {
    digitalWrite(ledPin, HIGH);
    if(low == 1) {
      count++; 
      t0 = millis();
      low = 0;
    }
  }
  else {
    digitalWrite(ledPin, LOW);
    low = 1;
  }
  
  if(currentTime-startTime == 1500) {
    if(count==1) {
      Serial.println("one time");
    }
    else if(count==2) {
      Serial.println("two time");
    }
      else {
        Serial.println(count);
      }
    count = 0;
    startTime = currentTime;
  }
}

What i am trying to do is, whenever a user puses the botton, according to number of times he pushes the botton inside 1.5 sec, some function will execute.

How is your button wired? Can it “bounce”

(deleted)

Good catch :slight_smile:

Let me help a bit more [color=red]int[/color] t0 = 0;

dineshlama:
I can't use commercially avialable switch in my project, since my project requres that switch botton has to be very easy to push with very little weight.

Not even one of these: https://www.jaycar.com.au/spdt-sub-miniature-microswitch/p/SM1036 ?

Oh - in your code, what happens when the button state is HIGH (switch is held down) but currentTime-t0 <= 200 (its been held down for less than 200 ms) ? Specifically, what happens to the value of t0?

Ok, that sub minature switch was interesting, i'll check wheather it is sold in india also or not. I have modified my code like this now: