Introduction: Easiest Method to Make an LED Fade With the Arduino Uno

Hi everyone, this is my first Instructable, and in it, I'll be showing you how to fade an LED with an Arduino Uno , 2 Jumper wires, 1 Resistor, and a breadboard.

Enjoy!

Step 1: What You Will Need.

1x 220 Ohm Resistor

2x Breadboarding Wires

1x Arduino

...and a computer with the Arduino IDE software installed.

Step 2: Attach the Ground Wire to the Arduino

Attach a jumper wire to the ground (GND) output pin on the Arduino.

Step 3: Attach a Jumper Wire to Pin 9 on the Arduino

Next, attach a jumper wire to Pin 9 on your Arduino.

Step 4: Breadboarding!

Now get out your breadboard out and attach the ground wire.

Step 5: Pin 9 Wire

Now take the wire leading from pin 9 on the Arduino and attach it behind the non-conductive space in the middle of the breadboard.

The reason for this is because the Arduino does not have a built-in resistor leading out of Pin 9, you will need to put one in of your own. Putting the Pin 9 wire on the other side will keep it from burning out your LED and will provide enough space to comfortably fit the resistor in.

Step 6: Insert the 220 Ohm Resistor

Now insert the resistor from the pin 9 wire an plug the other end beside the Ground wire.

Step 7: The LED

Now attach the LED on the breadboard.

Step 8: Plug in the Power!

Now plug in the Arduino into your computer. The board will power on, but the LED will not light up...not yet.

Step 9: Upload the Code to Your Arduino.

Open the Arduino IDE software, assuming you have already downloaded and installed it. (You can get it for free from: www.arduino.cc/en/Main/Software

Navigate to File>Examples>Basics>Fade. The script is included in the install, but if you do not have it, here it is.

/*
Fade
 This example shows how to fade an LED on pin 9
 using the analogWrite() function.
 This example code is in the public domain.
 */
int led = 9;           // the pin that the LED is attached to
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by
// the setup routine runs once when you press reset:
void setup() {
  // declare pin 9 to be an output:
  pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
  // set the brightness of pin 9:
  analogWrite(led, brightness);
  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;
  // reverse the direction of the fading at the ends of the fade:
  if (brightness == 0 || brightness == 255) {
    fadeAmount = -fadeAmount ;
  }
  // wait for 30 milliseconds to see the dimming effect
  delay(30);
}

Now upload the code to your board.

Step 10: Congratulations!

If you did everything right, after a few seconds, the led will begin to fade.

First Time Author Contest

Participated in the
First Time Author Contest