// C++ code
//
const int ledPin = 9;
void setup()
{
pinMode(ledPin, OUTPUT);
}
void loop()
{
// Gradually increase brightness
for (int brightness = 0; brightness <= 255; brightness++) {
analogWrite(ledPin, brightness); // Set LED brightness
delay(5); // Small delay for a smooth transition
}
// Gradually decrease brightness
for (int brightness = 255; brightness >= 0; brightness--) {
analogWrite(ledPin, brightness); // Set LED brightness
delay(5); // Small delay for a smooth transition
}
}