Answers for "pwm code for led arduino"

0

pwm code for led arduino

//Initializing LED Pin
int led_pin = 6;
void setup()
{ 
	//Declaring LED pin as output  
	pinMode(led_pin, OUTPUT);
}
void loop()
{ 
	//Fading the LED
	for(int i=0; i<255; i++)
{    
	analogWrite(led_pin, i);
	delay(5);
} 
	for(int i=255; i>0; i--)
	{  
	analogWrite(led_pin, i);
	delay(5); 
	}
}
Posted by: Guest on April-24-2021

Browse Popular Code Answers by Language