Ok not tested, but it compiles OK. Note that we are going to gradually turn on the led from full off to full on via PWM control of the led using analogWrite() commands. But pin 13 isn't one of the available PWM output pins, so we have to move the led to pin 10, and be sure to use a series resistor with the led. You can increase or decrease the speed of the ramping up of the LED by changing the value inside the delay(10) command.
Good luck;
Lefty
const int buttonPin = 2;
int PWMpin = 10; // LED in series with 470 ohm resistor on pin 10
int buttonState = 0;
void setup() {
pinMode(PWMpin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop(){
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
for (int i=0; i <= 255; i++){
analogWrite(PWMpin, i);
delay(10);
}
}
else {
digitalWrite(PWMpin, LOW);
}
}