Need button tweak and ending for 4-digit 7-segment countdown timer

Hi guys
I've read about a million different posts and sketches on doing this, but I still can't get my head around it.
I need a countdown timer for about 20 seconds that shows the 10ths of seconds after a decimal point, initiated by a button press. The timer counts down to zero and then lights up an LED. Pressing the button again resets the timer.

I found a sketch that works for me, but when I press the button it starts, but then if the button is released the timer resets.

My idea is to have a momentary switch begin the countdown (press once and release and the timer starts), then at 000.0 an LED lights up. Then the button can reset the countdown back to 20 seconds upon a second press. There is probably a simple fix but my brain is being dumb.
Using an Uno, with the common cathode 4-digit, 7-segment display SH5461AS. Using Windows, Arduino IDE version 1.0.6

Attached is the setup. Code below. Thanks for any help!

/*

Stop-Watch

Push button re-start the timer

*/

 

int a = 5;
int b = 6;
int c = 7;
int d = 8;
int e = 9;
int f = 10;
int g = 11;
int p = 0;

int d4 = 4;
int d3 = 3;
int d2 = 2;
int d1 = 1;

int LaunchLED = A5; //light up led for rocketlaunch

int startStopReset = 13; //button pin

 int buttonPushCounter = 0;   // counter for the number of button presses
int buttonState = 0;         // current state of the button
int lastButtonState =0;     // previous state of the button

// This variable gets toggled either high or low each time the button is pressed. 
// In other words, this variable changes states with each button press.
bool pressed = true;

int buttonpress;

long n = 30000; //start time: 300000 = 30s seconds

int x = 100;

int del = 55; 

 

void setup()

{
  pinMode(d1, OUTPUT);
  pinMode(d2, OUTPUT);
  pinMode(d3, OUTPUT);
  pinMode(d4, OUTPUT);
  pinMode(a, OUTPUT);
  pinMode(b, OUTPUT);
  pinMode(c, OUTPUT);
  pinMode(d, OUTPUT);
  pinMode(e, OUTPUT);
  pinMode(f, OUTPUT);
  pinMode(g, OUTPUT);
  pinMode(p, OUTPUT);


//launch mode light output
pinMode(LaunchLED, OUTPUT);

  pinMode(startStopReset, INPUT); //button input

  //digitalWrite(startStopReset, HIGH); 

}

 

void loop()

{

  clearLEDs();

  pickDigit(1);

  pickNumber((n/x/1000)%10);

  delayMicroseconds(del);

 

  clearLEDs();

  pickDigit(2);

  pickNumber((n/x/100)%10);

  delayMicroseconds(del);

 

  clearLEDs();

  pickDigit(3);

  dispDec(3);

  pickNumber((n/x/10)%10);

  delayMicroseconds(del);

 

  clearLEDs();

  pickDigit(4);

  pickNumber(n/x%10);

  delayMicroseconds(del);

 

  n--; //'n++' for stopwatch

 

  if (digitalRead(13) == LOW)

  {

    n = 20000; //re-start time: 200000 = 20s seconds

  }

}

 

void pickDigit(int x) 

{

  digitalWrite(d1, HIGH);

  digitalWrite(d2, HIGH);

  digitalWrite(d3, HIGH);

  digitalWrite(d4, HIGH);

 

  switch(x)

  {

  case 1: 

    digitalWrite(d1, LOW); 

    break;

  case 2: 

    digitalWrite(d2, LOW); 

    break;

  case 3: 

    digitalWrite(d3, LOW);

    digitalWrite(p, HIGH); //new 

    break;

  default: 

    digitalWrite(d4, LOW); 

    break;

  }

}

 

void pickNumber(int x)

{

  switch(x)

  {

  default: 

    zero(); 

    break;

  case 1: 

    one(); 

    break;

  case 2: 

    two(); 

    break;

  case 3: 

    three(); 

    break;

  case 4: 

    four(); 

    break;

  case 5: 

    five(); 

    break;

  case 6: 

    six(); 

    break;

  case 7: 

    seven(); 

    break;

  case 8: 

    eight(); 

    break;

  case 9: 

    nine(); 

    break;

  }

}

 

void dispDec(int x)

{

  digitalWrite(p, LOW);

}

 

void clearLEDs()

{

  digitalWrite(a, LOW);

  digitalWrite(b, LOW);

  digitalWrite(c, LOW);

  digitalWrite(d, LOW);

  digitalWrite(e, LOW);

  digitalWrite(f, LOW);

  digitalWrite(g, LOW);

  digitalWrite(p, LOW);

}

 

void zero()

{

  digitalWrite(a, HIGH);

  digitalWrite(b, HIGH);

  digitalWrite(c, HIGH);

  digitalWrite(d, HIGH);

  digitalWrite(e, HIGH);

  digitalWrite(f, HIGH);

  digitalWrite(g, LOW);

}

 

void one()

{

  digitalWrite(a, LOW);

  digitalWrite(b, HIGH);

  digitalWrite(c, HIGH);

  digitalWrite(d, LOW);

  digitalWrite(e, LOW);

  digitalWrite(f, LOW);

  digitalWrite(g, LOW);

}

 

void two()

{

  digitalWrite(a, HIGH);

  digitalWrite(b, HIGH);

  digitalWrite(c, LOW);

  digitalWrite(d, HIGH);

  digitalWrite(e, HIGH);

  digitalWrite(f, LOW);

  digitalWrite(g, HIGH);

}

 

void three()

{

  digitalWrite(a, HIGH);

  digitalWrite(b, HIGH);

  digitalWrite(c, HIGH);

  digitalWrite(d, HIGH);

  digitalWrite(e, LOW);

  digitalWrite(f, LOW);

  digitalWrite(g, HIGH);

}

 

void four()

{

  digitalWrite(a, LOW);

  digitalWrite(b, HIGH);

  digitalWrite(c, HIGH);

  digitalWrite(d, LOW);

  digitalWrite(e, LOW);

  digitalWrite(f, HIGH);

  digitalWrite(g, HIGH);

}

 

void five()

{

  digitalWrite(a, HIGH);

  digitalWrite(b, LOW);

  digitalWrite(c, HIGH);

  digitalWrite(d, HIGH);

  digitalWrite(e, LOW);

  digitalWrite(f, HIGH);

  digitalWrite(g, HIGH);

}

 

void six()

{

  digitalWrite(a, HIGH);

  digitalWrite(b, LOW);

  digitalWrite(c, HIGH);

  digitalWrite(d, HIGH);

  digitalWrite(e, HIGH);

  digitalWrite(f, HIGH);

  digitalWrite(g, HIGH);

}

 

void seven()

{

  digitalWrite(a, HIGH);

  digitalWrite(b, HIGH);

  digitalWrite(c, HIGH);

  digitalWrite(d, LOW);

  digitalWrite(e, LOW);

  digitalWrite(f, LOW);

  digitalWrite(g, LOW);

}

 

void eight()

{

  digitalWrite(a, HIGH);

  digitalWrite(b, HIGH);

  digitalWrite(c, HIGH);

  digitalWrite(d, HIGH);

  digitalWrite(e, HIGH);

  digitalWrite(f, HIGH);

  digitalWrite(g, HIGH);

}

 

void nine()

{

  digitalWrite(a, HIGH);

  digitalWrite(b, HIGH);

  digitalWrite(c, HIGH);

  digitalWrite(d, HIGH);

  digitalWrite(e, LOW);

  digitalWrite(f, HIGH);

  digitalWrite(g, HIGH);

}

OK, I think I figured it out. However the TX light is on and won't go off. Is that just because I am using pin 1?

Here is the updated code that works the way it should. One weird thing is that the display digits all go dark except for the rightmost one when it hits 0. After the LEDs come on and go off all the digits reappear.

Here is the updated code.

/*

Stop-Watch

Push button re-start the timer

*/

 

int a = 5;
int b = 6;
int c = 7;
int d = 8;
int e = 9;
int f = 10;
int g = 13;
int p = 0;

int d4 = 4;
int d3 = 3;
int d2 = 2;
int d1 = 1;

int LaunchLED = 11; //light up led for rocketlaunch
int AudioActivate = 12;
int buttonPin = A5; //button pin

 int buttonPushCounter = 0;   // counter for the number of button presses
int buttonState = 0;         // current state of the button
int lastButtonState =0;     // previous state of the button

// This variable gets toggled either high or low each time the button is pressed. 
// In other words, this variable changes states with each button press.
bool pressed = true;

int buttonpress;

long n = 20000; //start time: 300000 = 30s seconds

int x = 100;

int del = 55; 

 //fade integers for the launch LED
 int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by
 
 
 

void setup()

{
  pinMode(d1, OUTPUT);
  pinMode(d2, OUTPUT);
  pinMode(d3, OUTPUT);
  pinMode(d4, OUTPUT);
  pinMode(a, OUTPUT);
  pinMode(b, OUTPUT);
  pinMode(c, OUTPUT);
  pinMode(d, OUTPUT);
  pinMode(e, OUTPUT);
  pinMode(f, OUTPUT);
  pinMode(g, OUTPUT);
  pinMode(p, OUTPUT);


//launch mode light output
pinMode(LaunchLED, OUTPUT);
 pinMode(AudioActivate, OUTPUT);
 
  pinMode(buttonPin, INPUT); //button input

  //digitalWrite(buttonPin, HIGH); 

}

 

void loop()

{

  
  
  
  
  clearLEDs();

  pickDigit(1);

  pickNumber((n/x/1000)%10);

  delayMicroseconds(del);

 

  clearLEDs();

  pickDigit(2);

  pickNumber((n/x/100)%10);

  delayMicroseconds(del);

 

  clearLEDs();

  pickDigit(3);

  dispDec(3);

  pickNumber((n/x/10)%10);

  delayMicroseconds(del);

 

  clearLEDs();

  pickDigit(4);

  pickNumber(n/x%10);

  delayMicroseconds(del);

 

  n--; //'n++' for stopwatch




// read the pushbutton input pin:
  buttonState = digitalRead(buttonPin);
  
   // compare the buttonState to its previous state
   if (buttonState != lastButtonState) {
     // if the state has changed, increment the counter
     if (buttonState == HIGH) {
       // if the current state is HIGH then the button
       // wend from off to on:
       buttonPushCounter++;
       pressed = !pressed; //toggle state of the variable
       
       //digitalWrite(buttonPin, HIGH);
       
    // }else {
       digitalWrite(buttonPin, LOW);
   }
   }
    // save the current state as the last state, 
   //for next time through the loop
   lastButtonState = buttonState;
  
   // reset timer? every four button pushes by 
   // checking the modulo of the button push counter.
   // the modulo function gives you the remainder of 
   // the division of two numbers:
   if (buttonPushCounter % 4 == 0) {
     digitalWrite(buttonPin, LOW);
   } else {
    digitalWrite(buttonPin, HIGH);
   }
   // will this work?



// this is for the audio activation
if (n == 0)
{
  digitalWrite (AudioActivate, HIGH);
  delay(1000); // to make sure there is enough time for the "button press"
}
else {
  digitalWrite (AudioActivate, LOW);
}
  //


 //attempting to activate Launch LED on 000.0
 //super clunky solution for fading the led
if (n == 0){
  analogWrite (LaunchLED, 50);
delay (250);
analogWrite (LaunchLED, 150);
delay (25);
analogWrite (LaunchLED, 200);
delay (250);
analogWrite (LaunchLED, 225);
delay (250);
analogWrite (LaunchLED, 255);
delay (250);
    analogWrite (LaunchLED, 225);
delay (250);
analogWrite (LaunchLED, 200);
delay (25);
analogWrite (LaunchLED, 150);
delay (250);
analogWrite (LaunchLED, 50);
delay (250);
analogWrite (LaunchLED, 150);
delay (25);
analogWrite (LaunchLED, 200);
delay (250);
analogWrite (LaunchLED, 225);
delay (250);
analogWrite (LaunchLED, 255);
delay (250);
    analogWrite (LaunchLED, 225);
delay (250);
analogWrite (LaunchLED, 200);
delay (25);
analogWrite (LaunchLED, 150);
delay (250);
analogWrite (LaunchLED, 50);
delay (250);
analogWrite (LaunchLED, 150);
delay (25);
analogWrite (LaunchLED, 200);
delay (250);
analogWrite (LaunchLED, 225);
delay (250);
analogWrite (LaunchLED, 255);
delay (250);
    analogWrite (LaunchLED, 225);
delay (250);
analogWrite (LaunchLED, 200);
delay (25);
analogWrite (LaunchLED, 150);
delay (250);
analogWrite (LaunchLED, 50);
delay (250);
analogWrite (LaunchLED, 100);
//
analogWrite (LaunchLED, 150);
delay (25);
analogWrite (LaunchLED, 200);
delay (250);
analogWrite (LaunchLED, 225);
delay (250);
analogWrite (LaunchLED, 255);
delay (250);
    analogWrite (LaunchLED, 225);
delay (250);
analogWrite (LaunchLED, 200);
delay (25);
analogWrite (LaunchLED, 150);
delay (250);
analogWrite (LaunchLED, 50);
delay (250);

//


  
}
else {
  digitalWrite (LaunchLED, LOW);
}





  
  
  
if (pressed) //(buttonState == LOW) 


{

    n = 20000; //re-start time: 200000 = 20s seconds

  }

}

 

void pickDigit(int x) 

{

  digitalWrite(d1, HIGH);
  digitalWrite(d2, HIGH);
  digitalWrite(d3, HIGH);
  digitalWrite(d4, HIGH);


  switch(x)
  {

  case 1: 

    digitalWrite(d1, LOW); 

    break;

  case 2: 

    digitalWrite(d2, LOW); 

    break;

  case 3: 

    digitalWrite(d3, LOW);

    digitalWrite(p, HIGH); //new 

    break;

  default: 

    digitalWrite(d4, LOW); 

    break;

  }

}

 

void pickNumber(int x)

{

  switch(x)

  {

  default: 

    zero(); 

    break;

  case 1: 

    one(); 

    break;

  case 2: 

    two(); 

    break;

  case 3: 

    three(); 

    break;

  case 4: 

    four(); 

    break;

  case 5: 

    five(); 

    break;

  case 6: 

    six(); 

    break;

  case 7: 

    seven(); 

    break;

  case 8: 

    eight(); 

    break;

  case 9: 

    nine(); 

    break;

  }

}

 

void dispDec(int x)

{

  digitalWrite(p, LOW);

}

 

void clearLEDs()

{

  digitalWrite(a, LOW);

  digitalWrite(b, LOW);

  digitalWrite(c, LOW);

  digitalWrite(d, LOW);

  digitalWrite(e, LOW);

  digitalWrite(f, LOW);

  digitalWrite(g, LOW);

  digitalWrite(p, LOW);

}

 

void zero()

{

  digitalWrite(a, HIGH);

  digitalWrite(b, HIGH);

  digitalWrite(c, HIGH);

  digitalWrite(d, HIGH);

  digitalWrite(e, HIGH);

  digitalWrite(f, HIGH);

  digitalWrite(g, LOW);

}

 

void one()

{

  digitalWrite(a, LOW);

  digitalWrite(b, HIGH);

  digitalWrite(c, HIGH);

  digitalWrite(d, LOW);

  digitalWrite(e, LOW);

  digitalWrite(f, LOW);

  digitalWrite(g, LOW);

}

 

void two()

{

  digitalWrite(a, HIGH);

  digitalWrite(b, HIGH);

  digitalWrite(c, LOW);

  digitalWrite(d, HIGH);

  digitalWrite(e, HIGH);

  digitalWrite(f, LOW);

  digitalWrite(g, HIGH);

}

 

void three()

{

  digitalWrite(a, HIGH);

  digitalWrite(b, HIGH);

  digitalWrite(c, HIGH);

  digitalWrite(d, HIGH);

  digitalWrite(e, LOW);

  digitalWrite(f, LOW);

  digitalWrite(g, HIGH);

}

 

void four()

{

  digitalWrite(a, LOW);

  digitalWrite(b, HIGH);

  digitalWrite(c, HIGH);

  digitalWrite(d, LOW);

  digitalWrite(e, LOW);

  digitalWrite(f, HIGH);

  digitalWrite(g, HIGH);

}

 

void five()

{

  digitalWrite(a, HIGH);

  digitalWrite(b, LOW);

  digitalWrite(c, HIGH);

  digitalWrite(d, HIGH);

  digitalWrite(e, LOW);

  digitalWrite(f, HIGH);

  digitalWrite(g, HIGH);

}

 

void six()

{

  digitalWrite(a, HIGH);

  digitalWrite(b, LOW);

  digitalWrite(c, HIGH);

  digitalWrite(d, HIGH);

  digitalWrite(e, HIGH);

  digitalWrite(f, HIGH);

  digitalWrite(g, HIGH);

}

 

void seven()

{

  digitalWrite(a, HIGH);

  digitalWrite(b, HIGH);

  digitalWrite(c, HIGH);

  digitalWrite(d, LOW);

  digitalWrite(e, LOW);

  digitalWrite(f, LOW);

  digitalWrite(g, LOW);

}

 

void eight()

{

  digitalWrite(a, HIGH);

  digitalWrite(b, HIGH);

  digitalWrite(c, HIGH);

  digitalWrite(d, HIGH);

  digitalWrite(e, HIGH);

  digitalWrite(f, HIGH);

  digitalWrite(g, HIGH);

}

 

void nine()

{

  digitalWrite(a, HIGH);

  digitalWrite(b, HIGH);

  digitalWrite(c, HIGH);

  digitalWrite(d, HIGH);

  digitalWrite(e, LOW);

  digitalWrite(f, HIGH);

  digitalWrite(g, HIGH);

}