Project 3: Fade an LED's Brightness (Fade / Fading)

Created on: 2 August 2012

Tutorial 10 – Pages

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.

Parts Needed

  • 1 × LED (e.g. 3mm or 5mm red, green, blue, etc.)
  • 1 × 220 ohm resistor (1/4W 5%)

Arduino Website Page

Fade and Fading

In the Arduino IDE

File → Examples → 1.Basics → Fade


File → Examples → 3.Analog → Fading

Building the Circuit

Find the circuit diagram and connections on both the Fade and Fading pages.

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.

Programming and Operating the Circuit

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.

Project 3 Video

Can't see the video? View on YouTube →

← Go back to P2: DigitalReadSerialGo to P4: Button →