Fading LED Arduino example

Connect an LED to digital pin 3

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);
}

Related posts

Arduino and GY-21P readings on a web page

MPL3115A2 sensor readings displayed on a web page

Adafruit Neopixel shield examples