// Pin number for the LED
const int ledPin = 9;
void setup() {
// Set pin 9 as an output
pinMode(ledPin, OUTPUT);
}
void loop() {
// Gradually increase brightness
for (int brightness = 0; brightness <= 255; brightness++) {
analogWrite(ledPin, brightness); // Set LED brightness
delay(10); // Small delay for a smooth transition
}
// Gradually decrease brightness
for (int brightness = 255; brightness >= 0; brightness--) {
analogWrite(ledPin, brightness); // Set LED brightness
delay(10); // Small delay for a smooth transition
}
}