Go Down

Topic: Button Verify (Read 1 time) previous topic - next topic

jjvideo25

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

Coding Badly


PaulS

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

jjvideo25


bHogan

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

PaulS

Quote
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