help finishing my countdown timer

So i've made a countdown timer and it works fairly well for what i am doing, however i wanted to add a feature. as it is i have 4 buttons: 10 second countdown, 20 second countdown, 40 second countdown, and a reset. the feature i would like to add is if when reset is pressed during a countdown if it could store the time remaining so i could resume a few moments later with the press of the same reset button. i am also up for any other critiques as i have only been messing with my arduino for a few weeks. also keep in mind i have moved this project off of the uno and onto a attiny85 to save space and money as i plan to make a few of these, so interrupts are probably not an option. heres what i have so far...

//setup buttons and buzzer pins
const int buzz = 4;
const int butt1 = 0;
const int butt2 = 1;
const int butt3 = 2;
const int butt4 = 3;



void setup() {
 
//setup pinModes as input and outputs
 pinMode(buzz, OUTPUT);
 pinMode(butt1, INPUT);
 pinMode(butt2, INPUT); 
 pinMode(butt3, INPUT); 
 pinMode(butt4, INPUT);
 
//setup serial comunication for monitoring time
 Serial.begin(9600);  
}


void loop()

{

//button 1 sequence 
 if (digitalRead(butt1) == LOW)
 {
   
//beep twice for an audible confirmation of button press
   digitalWrite(buzz, HIGH);
   delay(50);
   digitalWrite(buzz, LOW);
   delay(50);
   digitalWrite(buzz, HIGH);
   delay(50);
   digitalWrite(buzz, LOW);

//10 second countdown
   for (int x = 10; x >= 0; x--)
   {
     if (x == 0) 
     {
       digitalWrite(buzz, HIGH);
       delay(2000);
       digitalWrite(buzz, LOW);
     }
     
//alow for a reset and beep three times if pressed
     if (digitalRead(butt4) == LOW)
    
     {
       digitalWrite(buzz, HIGH);
       delay(50);
       digitalWrite(buzz, LOW);
       delay(50);
       digitalWrite(buzz, HIGH);
       delay(50);
       digitalWrite(buzz, LOW);
       delay(50);
       digitalWrite(buzz, HIGH);
       delay(50);
       digitalWrite(buzz, LOW);
       break;
     }
     else
     {
     Serial.println(x);
     delay(1000);
     }
   }
 }
 
//button 2 sequence
 if (digitalRead(butt2) == LOW)
 {
   
//beep twice for an audible confirmation of button press
   digitalWrite(buzz, HIGH);
   delay(50);
   digitalWrite(buzz, LOW);
   delay(50);
   digitalWrite(buzz, HIGH);
   delay(50);
   digitalWrite(buzz, LOW);

//20 second countdown
   for (int x = 20; x >= 0; x--)
   {
     if (x == 0) 
     {
       digitalWrite(buzz, HIGH);
       delay(2000);
       digitalWrite(buzz, LOW);
     }
     
//alow for a reset and beep three times if pressed
     if (digitalRead(butt4) == LOW)
    
     {
       digitalWrite(buzz, HIGH);
       delay(50);
       digitalWrite(buzz, LOW);
       delay(50);
       digitalWrite(buzz, HIGH);
       delay(50);
       digitalWrite(buzz, LOW);
       delay(50);
       digitalWrite(buzz, HIGH);
       delay(50);
       digitalWrite(buzz, LOW);
       break;
     }
     else
     {
     Serial.println(x);
     delay(1000);
     }
   }
 }

//button 3 sequence
 if (digitalRead(butt3) == LOW)
 {
   
//beep twice for an audible confirmation of button press
   digitalWrite(buzz, HIGH);
   delay(50);
   digitalWrite(buzz, LOW);
   delay(50);
   digitalWrite(buzz, HIGH);
   delay(50);
   digitalWrite(buzz, LOW);

//40 second countdown
   for (int x = 40; x >= 0; x = x--)
   {
     if (x == 0) 
     {
       digitalWrite(buzz, HIGH);
       delay(2000);
       digitalWrite(buzz, LOW);
     }
     
//alow for a reset and beep three times if pressed
     if (digitalRead(butt4) == LOW)
    
     {
       digitalWrite(buzz, HIGH);
       delay(50);
       digitalWrite(buzz, LOW);
       delay(50);
       digitalWrite(buzz, HIGH);
       delay(50);
       digitalWrite(buzz, LOW);
       delay(50);
       digitalWrite(buzz, HIGH);
       delay(50);
       digitalWrite(buzz, LOW);
       break;
     }
     else
     {
     Serial.println(x);
     delay(1000);
     }
   }
 }
 
}

Hi,
So you want your reset to pause?
Can you fit another button and call it PAUSE?

Can you go back and edit your posting using code tags please.

Please use code tags.. See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

Tom..... :slight_smile:

So I thought the reset did just that, reset the CPU so did not enable any other things to be done.

So it looks like you need another button.

Weedpharma

you should at least get rid of all those delay() calls to make the button responsive.

Check the blink without delay example how to do that

I will try using millis() I've never done it before but I agree it would be more precise, but if I use millis will I still be able to use a for loop? Or will I just use an if statement for each button with the button defining the total interval (10,20,40)? Because I like having the serial.print for each second and also I'd like to in the future ad a 7 segment lcd to let me know how much time is left. I do not want to add another button I'd like to say something like: if the reset/pause button is pressed int x stays at its current value. so that at that point I have the option to use the 10,20,30, buttons or resume the last paused value with the fourth button