Break from while loops after specific time

Do you set the clock in your house to twelve o'clock when you boil an egg :smiley: No, you don't. You look at the clock, note down the time and check the clock regularly to see if the desired time has lapsed.

Below will need some fine tuning but (hopefully) shows the approach

  char counter = 0;
  uint32_t startTime;

  do {
    counter++
    if (counter == 1)
    {
      startTime = millis();
    }
    //do stuff
  } while (.... && (millis() - startTime < 1000));

  couter = 0;