int ledPin = 2; // the number of the LED pin
int brightness = 0; // how bright the LED is
int fadeAmount = 25; // how many points to fade the LED by
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
analogWrite(ledPin, brightness);
brightness = brightness + fadeAmount;
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
delay(30); // wait for 30 milliseconds to see the dimming effect
}