Just want to fade an LED in with button and back out

Hi I just want to program my Arduino to fade LEDs in with one button press and then stay on. Then with the next button press I want it to fade out and stay off. Any tips or thoughts would be appreciated.

const int buttonPin = A0;     // the number of the pushbutton pin
const int ledPin =  5;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);     
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { 
      // sets the value (range from 0 to 255):
      analogWrite(ledPin, fadeValue);         
      // wait for 30 milliseconds to see the dimming effect    
      delay(30);                            
    } 
  }
  else {
    // turn LED off:
    for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { 
      // sets the value (range from 0 to 255):
      analogWrite(ledPin, fadeValue);         
      // wait for 30 milliseconds to see the dimming effect    
      delay(30);                            
    } 
  }
}

i think that this line is your problem

const int buttonPin = A0;     // the number of the pushbutton pin

you have your pushbutton on an analog pin, and you are calling digitalRead later on. Instead of using pin A0 you need to use a digital pin instead.

connect one side of button to a digital input pin, run a resistor to ground on that same side, and the other side of button to +5v

thanks ill try that. All its doing is when I hold the button it fades in over and over again and when the button is released its the opposite whichi I guess is what its coded to do. lol. i have a long ways to go, feeling retarded.... :angry:

also i notice that you don't have a variable for the button state or the previous button state.. check out this tut http://arduino.cc/en/Tutorial/ButtonStateChange