const int ledPin = 9;
int rate = 12;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
// Ramp up the LED brightness from 0 to maximum
for (int brightness = 0; brightness <= 255; brightness++) {
analogWrite(ledPin, brightness); // Set the LED brightness
delay(rate); // Adjust delay for brightness change rate
}
delay(1000); // Run at maximum brightness for 1 second
for (int brightness = 255; brightness >= 0; brightness--) {
analogWrite(ledPin, brightness); // Set the LED brightness
delay(rate); // Adjust delay for brightness change rate
}
delay(1000); // Wait for 1 second before restarting the cycle
}