## Introduction: Project 6 : Led Fading With PWM

Today we are going to learn how to fade an led with a PWM pin. First we will see what is PWM. PWM stands for Pulse W

## Step 1: What You Require?

1. Arduino Uno or Arduino Mega 2560 (They are the beginning boards of Arduino)
2. Jumper Wires (Male to Male)
3. 1 Led's
5. 10 K (more preferable) or 1k resistors

## Step 2: Build Your Circuit and Know Why Is It Designed So?

The above diagram shows blue lines which represents the Jumper Wires. Jumper Wires are connective units. They transfer power and do a lot of jobs. In this program they are only transferring power. An Led requires 2 types of power to light it up. Positive and Negative. Positive Energy is supplied by Digital Pins which is distinct than the other Pin giving Positive Energy by its name. It's vice versa for identifying the source of power and where is it transferred. An led when directly supplied by positive energy fuses up that's why we use a resistor. Before me move forward let's discuss about the positive negative rods of the led. The longer is positive and the shorter is negative. The resistor is connected with the positive rod which goes in the same row. In the same column but different row of the other end of the resistor comes the jumper wire connecting it with the digital pin.

Negative energy is noted as GND and is directly supplied to the shorter rod of the Led using a Jumper Wire. That completes the circuit diagram and why is it placed or designed in this way.

The digital pin that is providing positive energy is also a PWM pin and a PWM pin is able to perform analog activities.

## Step 3: Now for the Software and Understanding It

1. int led1 = 9;
2. int brightness = 0;
4. void setup()
5. {pinMode(led1, OUTPUT);}
6. void loop()
7. {analogWrite(led1, brightness);
8. brightness = brightness + fade;
9. if (brightness == 0){