Total number of count when buttonstate goes HIGH with in one second loop

Hi guys,

I'm new for Arduino. Please help me to done this scenario below. When I pressing the button 2 times in one second print the count value as two when state goes HIGH.

If I change the time limit, then print the pressed count accordingly. Please anyone advice me.

My advice to you is to read the datasheet. The on-board timer/counters are called that for a reason. Each has a dedicated pin designed to count incoming pulses. You can read/clear the counter over whatever time period you want. You can also use a pin change interrupt to achieve to same result but then you'll need to set up the counter in the interrupt service routine.

Thanks for your response. I tried to get count within one second using interrupt function but it still can’t generate accurately from given button pressed. Actuall I’m doing for a calculation of RPM count but first it needs revolution per second… Please find my code

RPM count.pdf (1.05 MB)

If anyone having code for measuring the RPS and RPM of a motor using the Arduino controller? Please help me.