Controlling Brightness of a LED



In this tutorial, we will learn how to control the brightness of a LED without using any sensors.

Since we all know how a LED works and what all can be done with it let us start the tutorial.

For those of you who are new kindly refer our previous blogs to explore LED’s. 


Components required

  • Led                                      1No.
  • Arduino UNO                        1No.
  • Few connecting wires.

The circuit connection is very simple just connect the anode of the Led with the 11th pin of Arduino and connect the cathode with the ground.

After making the connections dump the code given below.

int  i;
void setup()
{
}
void loop() {
for (i = 0; i < 256; i++)
{
analogWrite(11, i);
delay(10);
}
for (i = 256; i >0 ; i--)
{
analogWrite(11, i);
delay(10);
}
}



You will observe the output as:


Thinking?
Join our hands-on training courses.
To know more visit us at: http://www.sudolearn.com/
Next
Previous