Timeout in setup() function //waiting for numeric keyboard input

Dear All,

During the setup() I have to register two PINcodes from numeric keyboard. Everything is working fine, but if there is no input at this section the Arduino will wait forever.. (Unfortunately at this project it is not possible to put these in the loop..).

Is there any idea how can I make some timeout(s) just not to wait forever and start the setup again?

Thanks for your help!
Best regards,
V.

Surely the whole point of having pin codes is that you do want to wait forever?

PNViktor:
Unfortunately at this project it is not possible to put these in the loop…

It is possible.

void loop () {
static bool gotPins;

  if (!gotPins) {
    // get pin and after you got it set gotPin to true
  } else {
    // the 'real' loop action
  }
}

That wastes cpu cycles :wink:

PNViktor:
Is there any idea how can I make some timeout(s) just not to wait forever and start the setup again?

Yes. Start a timing and in your loop that you use to read the user input and compare the current time in the loop with the start time.