Search wiring.org.co:

This example is for Wiring version 1.0 build 0100+. If you have a previous version, use the examples included with your software. If you see any errors or have comments, please let us know.

RGB LED by BARRAGAN http://barraganstudio.com
Demonstrates the use of PWM pins (analog output) to change the color of an RGB LED. On Wiring v1 boards the PWM capable pins are: 29, 30, 31, 35, 36 and 37 On Wiring S board the PWM capable pins are: 4, 5, 6, 7, 19 and 20

    int REDPin = 4;    // RED pin of the LED to PWM pin 4
    int GREENPin = 5;  // GREEN pin of the LED to PWM pin 5
    int BLUEPin = 6;   // BLUE pin of the LED to PWM pin 6
    int brightness = 0; // LED brightness
    int increment = 5;  // brightness increment

    void setup()
    {
      pinMode(REDPin, OUTPUT);
      pinMode(GREENPin, OUTPUT);
      pinMode(BLUEPin, OUTPUT);
      Serial.begin(9600);
    }

    void loop()
    {
      brightness = brightness + increment;  // increment brightness for next loop iteration

      if (brightness <= 0 || brightness >= 255)    // reverse the direction of the fading
      {
        increment = -increment;
      }
      brightness = constrain(brightness, 0, 255);
      analogWrite(REDPin, brightness);
      analogWrite(GREENPin, brightness);
      analogWrite(BLUEPin, brightness);

      delay(20);  // wait for 20 milliseconds to see the dimming effect
    }