Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Counting the seconds a button keep being pressed.

Status
Not open for further replies.
if you check every 100ms for 3 seconds(3000ms) then you can setup a timeVar to increment every 100ms and if the value is 3000/100 =30 then its been held down the entire time.

You can also simple have it stop when the button goes low. :D but if you do it by using a variable and counting you can achieve more like...

1 second the var would be 10
2 seconds the var would be 20
3 seconds the var would be 30

Then you can check to see where the value is in between and have different function easy :D


Hey, thats exactly what I did :) Thanks!
I used a counter and counted until 30.
I just checked it and it works well, of couse I'll need to double check it when I'm less tired.

At first, I set the Momentary_Pressing_time to 100ms, and was wondering why when I pressed it a regular short press it didnt do anything, I thought there was something wrong with the mechanism.
But after debugging it, I relazied that a regular short pressing lasts somewhere between 100msec and 200msec :)

So right now I consider a regular pressing as any pressing that lasts up to 200mSec.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top