How Can You Switch Between Two Codes?

Using Arduino UNO

Say I have a LED blinking once every second and another code that will make it blink very fast. Is there away to have it all on one chip, and switch between the two codes with a momentary switch? The only thing I can find on the web is about on-off switch. I guess I'm looking for a on-on switch to switch the flash pattern of the led.
If its possible could someone please show me example with the following two codes?

void setup() {

  pinMode(13, OUTPUT);
}


void loop() {
  digitalWrite(13, HIGH);
  delay(1000);
  digitalWrite(13, LOW);
  delay(1000);
}
void setup() {

  pinMode(13, OUTPUT);
}


void loop() {
  digitalWrite(13, HIGH);
  delay(200);
  digitalWrite(13, LOW);
  delay(200);
}

Just put a 5x or 1x multiplier in your delay() parameter, the value of which is toggled by the momentary switch.

Put each of the sets of code in their own function and call the appropriate one when required by reading the input in loop().

NOTE that there will only be one setup() and loop() function in the program.

Something like this (not tested)

byte switchPin = 7;
boolean switchState;

void setup() {
    pinMode(switchPin, INPUT_PULLUP);
    pinMode(13, OUTPUT);
}

void loop() {
    switchState = digitalRead(switchPin);
    if (switchState == HIGH) {
        slowBlink();
    }
    else {
        fastBlink();
    }
}

void slowBlink() {
    digitalWrite(13, HIGH);
    delay(1000);
    digitalWrite(13, LOW);
    delay(1000);
}

void fastBlink() {
    digitalWrite(13, HIGH);
    delay(200);
    digitalWrite(13, LOW);
    delay(200);
}

For anything but a very simple program it is better to use millis() to manage timing without blocking. See Several Things at a Time

...R

The next question you're going to ask is "why does it take two seconds for the switch setting to take effect?", which is why it is really important not to use "delay()".

Useful hint:

pauseValue = 1200 - pauseValue;

prefer a non-blocking method to using delay()

you can play with this, which will switch to fast if you put an 'F' into the serial monitor and slow if anything else (not tested):

enum State{
  SLOW,
  FAST
};

State state = SLOW;
const byte ledPin = 13;

void setup() 
{
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}

void loop() 
{
  if(Serial.available())
  {
    if(Serial.read() == 'F')
    {
      state = FAST;
    }
    else
    {
      state = SLOW;
    }
  }
  switch(state)
  {
    case FAST:
      fastToggleLED();
      break;
    case SLOW:
      slowToggleLED();
      break;
  } 
}

void fastToggleLED()
{
  static unsigned long fastLedTimer;
  if (millis() - fastLedTimer >= 100UL)
  {
    digitalWrite(ledPin, !digitalRead(ledPin));
    fastLedTimer = millis();
  }
}
//
void slowToggleLED ()
{
  static unsigned long slowLedTimer;
  if (millis() - slowLedTimer >= 1250UL)
  {
    digitalWrite(ledPin, !digitalRead(ledPin));
    slowLedTimer = millis();
  }
}