Pages: [1]   Go Down
Author Topic: Button Verify  (Read 1573 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

Is there a way to make it so you have to hold a button down for 2 seconds to make the arduino take action?

Thanks ;D
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 208
Posts: 12931
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Yes.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49385
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Each pass through loop, see if a switch is pressed. If it is, but was not before, record the time.

Each pass through loop, see if the button is pressed, and was pressed before. If it is, see if it has been more than two seconds since the button was pressed. If it has, do something.

You know, I presume, how to check that a switch is pressed, and how to use millis() to observe the "time".
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

code please?
Logged

Denver
Offline Offline
God Member
*****
Karma: 20
Posts: 779
Inactive - PM
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

yuck! :smiley
Logged

"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom."
~ Clifford Stoll

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49385
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
code please?
OK. Here's a start:

Code:
// Put some stuff here

void setup()
{
   // May want to put some stuff here
}

void loop()
{
   // Put some stuff here
}
You should know how to read whether a switch is pressed (digitalRead). You should know how to save the previous state (=).
You should know how to determine how much time has elapsed (millis).
It's trivial putting the stuff together in the right order.

If that last assumption is false, make a stab at it, and post your code here for help.
Logged

Pages: [1]   Go Up
Jump to: