long press button

guys, do you have a snippet for detecting a button that is long pressed maybe for one second. thanks in advance.

Depends on when you want the detection to occur, is it on release or is it when it has been down for a certain time?

when it is down for a certain amount of time sir.

Jeff has a nice code for button click, double click, hold & long hold. Please look it Jeff's Arduino Blog: 4-Way Button: Click, Double-Click, Hold, Long Hold

thanks nadir. the problem is im really a noob in programming. not in electronics tho. i’ll try to separate the long press code here. i’m really lostabout this one…

So you want to detect when the button is first held down. That is you remember what it was the last lime you looked in the loop() and look again. When it was un-pressed last time and pressed this time ( use an if statement to find out) you then transfer the value of millis() into a variable.
Then each time round the loop you check if the value of millis() minis the time when the button was first pushed is greater than the time you want to start your action. If it is do what you want to do on a long press detection.

sir, i think that the number for or the long hold feature is suitable for my project.. but i cannot realy extract it from the long code of master jeff . huhu. thanks for the explanation tho. i'll try to understand the number three feature.

*number four feature