Watchdog setting, or a better way to press button to resume a timed sequence

I have a project that I am working on. It is using relays in a pseudo-random order for on for a few seconds at a time.

The installation has a button, that the user can press to start. when pressed will run through the previously mentioned order using relays to operate water features. In the control box I want a pot that the operator(not player) can set the play_time runtime between 1 and 10 minutes, started by a button press.

It my init, I was thinking of reading the pot and setting the play_time variable. once I have my number 1 through 10 it will sit and wait for someone in the installation to press the "go" button to run through the actions of the relays.

Using a lookup table to decide what relay to fire and for how long, (or what relay is active for how many seconds).

Because it is using water, I want to use as little as possible, and not run the unit with no one there, it needs to shut off until the next person wants to play and presses the "go" button. When the "go" button is pressed, I want the order to pickup from where it left off in the table not the beginning. (anti-cheating)

I have stumped myself on how to do so. I believe the watchdog will allow the code to continue where it left off, when the "go" button interrupts and wakes the Arduino.

The Arduino will be RESET when the pot needs to be read, if the play time needs to be changed. Starting from the beginning of the lookup-table is fine in this case.

If the watchdog timer starts then, relays start clicking away, then the watchdog time runs out and puts the Arduino to sleep until the button is pressed to wake the Arduino. Does the watchdog timer reset at this point?

Is the watchdog the best thing to use?

I thank you all for your time.

I’m not sure how the watchdog timer would be useful in this situation. Typically the watchdog timer is used for three purposes:

  • Automatically reset the microcontroller if the code stops running correctly.
  • Wake from sleep after a given interval.
  • Intentionally reset the microcontroller (to activate the bootloader for example).

I see no reason to reset in order to read the potentiometer. You could read the potentiometer after a given interval or whenever the start button is pressed, depending on how responsive you want to Arduino to be to play time adjustments. If you only read when the pot when the start button is pressed then you won’t be able to change the play time of an active session.

Here’s what I’d do, in pseudo code:

void setup() {
  // set pin modes
  // put the microcontroller to sleep

void loop() {
  // microcontroller is woken by the start button
  // read pot and set play_time accordingly
  startTimestamp = millis();
  while (millis() - startTimestamp < play_time) {
    // run water feature
  // put the microcontroller to sleep

How would that allow my code to continue from its stop point in order to continue from where it left off when the time ran out?

Post your code (using code tags, please) and I'll tell you.