Button issue

I am very new to programming and I am having trouble with push buttons. I'm fine with using one to control an led on or off. My problem is this. I want to do this to where when it starts, the led is blinking on and off with half second intervals (I'll call this function SLOW), then by pushing the button i call another function that blinks on and off with 100 milisecond intervals (FAST), then again to go back to the first function (SLOW). I just dont know how to get it to repeat a function over and over instead of just going through it once if it isn't in the loop function itself.

digitalWrite(ledpin, HIGH);
delay(500);
digitalWrite(ledpin, LOW);
delay(500);

again like i said my problem is that it will do that one time when I call it up but i dont understand how to make it loop.

forgive me again I am extremely new to this.

Thanks
Blaine

I'm sorry I didn't post what I've got so far. Please tell it like it is I just want to learn what I'm doing wrong.

const int ledpin = 10;
const int button = 2;

int buttonstate = 0;
int laststate = 0;

void setup()
{
pinMode(ledpin, OUTPUT);
pinMode(button, INPUT);
Serial.begin(9600);
}

void loop()
{
buttonstate = digitalRead(button);

if (buttonstate != laststate)
{
if (buttonstate == LOW)
{
digitalWrite(ledpin, HIGH);
delay(500);
digitalWrite(ledpin, LOW);
delay(500);
}
}
else
{
digitalWrite(ledpin, HIGH);
delay(100);
digitalWrite(ledpin, LOW);
delay(100);
}
laststate = buttonstate;
}

What you have to remember is that your program is looping - every time "loop()" exits, it gets called again immediately.

So, each time you start "loop()", you'll read the input again.

Your program has to remember the state it was in last time it executed "loop()".

Unless you get rid of the "delay" statements, your program is going to be unresponsive, so have a look at the "Blink without delay" tutorial, or have a look around the forum for "finite state machines".

Thank you very much I appreciate the prompt response. I think I spoke too soon lol. I did a bit more research and figured it out then read your response and it made it much clearer. Again thank you

thanks,
Blaine