int redPin = 5; int greenPin = 6; int bluePin = 13; // the pins that are attached to LEDs int brightness = 0; // how bright the LED is int fadeAmount = 5; // how many points to fade the LED by // the setup routine runs once when you press reset: void setup() { // declare pins to be an output: pinMode(redPin, OUTPUT); pinMode(greenPin, OUTPUT); pinMode(bluePin, OUTPUT); } // the loop routine runs over and over again forever: void loop() { #ifdef COMMON_ANODE red = 255 - red; green = 255 - green; blue = 255 - blue; #endif // set the brightness of the pins analogWrite(redPin, brightness); analogWrite(bluePin, brightness); analogWrite(greenPin, brightness); // change the brightness for next time through the loop: brightness = brightness + fadeAmount; // reverse the direction of the fading at the ends of the fade: if (brightness == 0 || brightness == 255) { fadeAmount = -fadeAmount ; } // wait for 30 milliseconds to see the dimming effect delay(30); }