LED fade out when button pressed

Hi i want to have a LED to turn on when a button is pressed but after (about) 4 seconds then LED fades out (fade time 1 second). I preferably want all the code to be inside the if brackets of the button.

Can someone Write or link me to some code

Thanks
Ian Scott

Have you looked at any of the examples in the IDE ?
There are separate examples of how to read a button press, wait a while and fade an LED. Put the techniques together and you will have what you want.

Is this homework by any chance ?

I preferably want all the code to be inside the if brackets of the button.

Can you post a picture of the button with if brackets?

Can you explain how the code can be inside those if brackets?

so all the code would be in the if(button == HIGH){ fading code}

You presumably mean

if(digitalRead(buttonPin) == HIGH)
  { 
    //fading code goes here
  }