Programming Examples

Arduino program to fade the led bulb using for loop


Arduino Code to fade the Lead 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()

CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz