Created on: 2 August 2012
One of the PWM (Pulse Width Modulator) pins is used to fade an LED from dim to bright and back to dim continuously.
There are two example sketches built into the Arduino IDE that will both operate this circuit. One is called Fade and the other is called Fading. The only difference between the two is that slightly different code has been used in the two sketches to achieve the same result.
File → Examples → 1.Basics → Fade
File → Examples → 3.Analog → Fading
Connect the 220 ohm resistor to Arduino pin 9. Connect the other end of the resistor to the anode of the LED. Connect the cathode of the LED to one of the Arduino GND pins.
In the Arduino IDE, select either File → Examples → 1.Basics → Fade or File → Examples → 3.Analog → Fading to open the sketch for this project. Verify and upload the sketch.
After loading the sketch, you will see the LED continually get brighter and then dimmer.
Can't see the video? View on YouTube →