Go Down

Topic: Button Verify (Read 2005 times) previous topic - next topic



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

Coding Badly


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".



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


code please?

OK. Here's a start:

Code: [Select]
// 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.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131