Circuit Arduino Uno
According to how long it stays in 5V and 0V (using the delay() function) you can obtain the fade effect. If delay() has a low value (for example 50ms or 0.05s) the fading speed will be higher because the Arduino will keep the voltage at pin 11 at a certain value only for 50ms then executes the next for() loop.
When the light intensity reaches the highest point then the second for() loop enters in action. This one will decrease the value of the output voltage on pin 11.
Script Fade LED In and Out