Demonstrates the use of analog output (Pulse Width Modulation (PWM)) to fade an LED. PWM is a technique for getting an analog-like behavior from a digital output by switching it off and on very fast.
An LED connected to digital output pin 9 through a 220-ohm resistor.
This example shows how to fade an LED using the analogWrite() function.
* LED attached from digital pin 9 to ground.
Created 1 Nov 2008
By David A. Mellis
modified 30 Aug 2011
By Tom Igoe
This example code is in the public domain.
Read more: Fading using an Arduino