Long Press Button to Run and Stop program

Hi I am New to arduino and have a mid complex prototype to realize.

I gather there and there on the forum for solutions that could answers some of my questions.

My prototype has a rotary encoder with press button. This presse button will be used for:

  • long press, on/off
  • short press, select
  • double press, validate

Increasing and decreasing values with rotation will be for an other topic.

My main headache is how can I, when the prototype is powered on, make the main program to run by the long press of the button, initializing a routine to start, and initialize an other routine to go back to a "standby" mode when long pressed again while main program is running...

Any help advice or direction will be highly appreciated .

:wink: