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: $1644.10
Top Donor: C.C. $100
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 →