I would like to make a countdown with arduino. To do this I'm using the millis () function, but I have a problem, I can not reset this. Reading on the internet I read that it is not possible to do this. So how can I find an alternative for this? In practice, when I pressed the button I started the countdown, while if I put it back, I went into the pause mode.

void inizio(){

  currentMillis1_general = millis();
  total_1 = currentMillis1_general - currentMillis_general;

  buttonState = digitalRead(buttonPin);
  if(buttonState == HIGH){
    step_funzione = 1;

void countdown(){


  currentMillis_general = millis();
  total_general = currentMillis_general - total_1;

  if(total_general - previousMillis_general >= interval_general){
    previousMillis_general += interval_general; 
    //previousMillis_general = currentMillis_general;
    m = new_tempo/60;
    s = new_tempo%60;

  display.showNumberDec(m, true,2,0);
  display.showNumberDec(s, true,2,2);


  buttonState = digitalRead(buttonPin);
  if(buttonState == HIGH){
    step_funzione = 0;
  • 3
    think about this ....How do you know when it is time to replace the oil in your car's engine? .... you cannot reset the odometer to zero
    – jsotola
    Jun 24, 2018 at 19:10

1 Answer 1


A way to accomplish "Reset" is to set your starting value equal to millis() again. To do the equivalent of "Pause", you need a pause counter. When you begin a pause, save millis() to pauseTime. When you resume running again, add millis() - pauseTime to your pauseCounter. Then your interval should not expire until millis() - pauseCounter > Interval).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.