int brightness = 0;
int fadeAmount = 3;
void setup() {
pinMode(18, OUTPUT);
}
void loop() {
analogWrite(18, brightness);
brightness = brightness + fadeAmount;
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
delay(20);
}