Amherst College Electronics Club: ATmega328 sample program for using the PWM
This little program is used to turn an LED on/off by increasing/decreasing it brightness at a sinusoidal rate. It uses pulse width modulation to control the brightness by altering the duty cycle of a square wave.