Syntax question

I’m new to this so bear with me…

I need to read a pushbutton pressed down for 5 seconds (to use as an emergency off for a motor) how would i do this?

Hi, and welcome to the Arduino forums!

You'll need to read the time when the button's state changed from unpressed to pressed, and then measure 5 seconds (5000 milliseconds) from that moment, if the elapsed time reached 5000 millis since press before the button is unpressed again, then you have your emergency. You can use the millis() time function to measure the time elapsed since the press.

Good luck!

-- Edit: added a welcome ;)

thanks that helped alot. But....

I got another one for ya. I need a syntax for leaving a protocol and returning to the loop

I got another one for ya. I need a syntax for leaving a protocol and returning to the loop

I didn't understand what you said :-?

Did you mean to ask how to keep track of time and button at the same time? Or am I awfully confused?

What like leaving the main loop to perform some other functions then return back to the loop?

You mean something like this?

void setup()
{
}

void loop()
{
  ...
  ...
  ...
  jumparound(); // jumps down to the fuction labeld jumparound
  ...
  ...
}

void jumparound()
{
  ...
  ...
  ... // at the end of this the program returns back to where
      // it left off in the loop
}