Programming Examples
Arduino program to fade the led bulb using for loop
Write a Arduino Code to fade a LED bulb using For loop and repeat the Process
void setup()
{
 // pinMode(10, OUTPUT);
 //to analogWrite
}
void loop()
{
 for(int a=0;a<=255;a++)
 {
 analogWrite(10,a);
 delay(10); // Wait for 10 millisecond(s)
 }
 for(int a=255;a>=0;a--)
 {
 analogWrite(10, a);
 delay(10); // Wait for 10 millisecond(s)
 }
}
Output
In digitalWrite() we can write only HIGH and LOW but if we want to write some other values means between 0 to 1 the we need to analogWrite. when we use analogWrite() the we don't need to set pinMode()