Home Code Fading LED

Fading LED

by shedboy71

Connect an LED to digital pin 3

Code

void setup()
{
pinMode(3, OUTPUT);
}

void loop()
{
for (int a = 0 ; a < 256 ; a++)
{
analogWrite(3, a);
delay(5);
}
for (int a = 255 ; a >= 0 ; a--)
{
analogWrite(3, a);
delay(5);
}
delay(200);
}
Share

You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More