Enough blinking! NOW FADE YOUR LED’s. :D

This project is a follow up to the basic blinking tutorials that i had earlier posted.
Here I will fade the LED’s connected to the breadboard.
This project requires you to already have basic breadboarding skills.

HARDWARE REQUIRED :-

  1. Arduino Uno
  2. Breadboard
  3. jumper wires
  4. 330 ohm resistors
  5. LED’s

 How your Code should look. :-

5.JPG

How your circuit should look like :-

Snapchat-1513660931[1].jpg

The explanation of the code is given along with the code.

It is highly recommended that you try the previous projects on LED’s and then get your hands on this one.

What you can variate here?

I  built this program for a single LED. I will suggest you to build this for two or three LED’s at a time all you will be needing is some more jumper wires, a couple of resistors, LED’s and a little variation to the code mentioned above.

For three LED’s the code will look like something like this :-

int led = 9
int led1 = 10
int led2 = 11;
int brightness = 0; //how bright the led is actually at the beginning
int fadeAmount = 5; //how many point to fade the led by
//the setup routine runs once you press the reset
void setup() {
//declare the pins to be output
pinMode(led, OUTPUT);
pinMode(led1,OUTPUT);
pinMode(led2, OUTPUT);

}

void loop() {
//set the brightness of pins
analogWrite(led,brightness);
analogWrite(led1,brightness);
analogWrite(led2,brightness);
//change brightness for next time through the loop
brightness = brightness + fadeAmount;
//reverse direction of fading at the end of the fade
if(brightness==0 || brightness==255)
{
fadeAmount = -fadeAmount;
}
delay(100);

}

Please note the connection made in the circuit is simple and same as what we did in the blink program.

Thankyou.

Follow my page for more  arduino projects.

http://www.electromaniweb.wordpress.com

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s