int i = 0;
void setup() {
pinMode(9, OUTPUT); // Set pin 9 as output
Serial.begin(9600); // Start the serial communication
}
void loop() {
// Increase brightness
for(i = 0; i <= 255; i += 5) {
analogWrite(9, i); // Set the brightness to 'i'
Serial.println(i); // Print the current value of 'i'
delay(100); // Wait for 100 ms
}
// Decrease brightness
for(i = 255; i >= 0; i -= 5) {
analogWrite(9, i); // Set the brightness to 'i'
Serial.println(i); // Print the current value of 'i'
delay(100); // Wait for 100 ms
}
while(true){} // Wait for 1 second before starting again
}