Fade (PWM)
analogWrite() on pin 9: the LED breathes.

The code
// analogWrite() on a PWM pin: the LED breathes in and out.
const int LED = 9;
void setup() {
pinMode(LED, OUTPUT);
}
void loop() {
for (int v = 0; v <= 255; v += 5) {
analogWrite(LED, v);
delay(20);
}
for (int v = 255; v >= 0; v -= 5) {
analogWrite(LED, v);
delay(20);
}
}