Starting Electronics Needs Your Help!
It is that time of the year when we need to pay for web hosting and buy new components and equipment for new tutorials. You can help by making a donation. Contribute to this website by clicking the Donate button. The total will be updated once daily. (You may need to clear your browser cache to see the updates.)

Target Amount: $2000
Amount Raised: $495

Donations Received

Top Donor: D.C. $30

X

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%)

Amazon.com

Amazon.co.uk



Arduino Website Page

Fade and Fading

In the Arduino IDE

File → Examples → 1.Basics → Fade

and

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 →