int redPin = 6;
int greenPin = 5;
int bluePin = 3;
void setup()
{
 pinMode(redPin, OUTPUT); // set redPin as output
 pinMode(greenPin, OUTPUT); // set greenPin as output
 pinMode(bluePin, OUTPUT); // set bluePin as output
}
void loop()
{
 setColor(255, 0, 0); // red color
 setColor(0, 255, 0); // green color
 setColor(0, 0, 255); // blue color
}
void setColor(int red, int green, int blue) //Subroutine
{
red = 255 - red; //remove "//' for anode(+) RGB LED
green = 255 - green; //remove "//' for anode(+) RGB LED
blue = 255 - blue; //remove "//' for anode(+) RGB LED
analogWrite(redPin, red); 
// connection to pin and set red value
analogWrite(greenPin, green); 
// connection to pin and set green value
analogWrite(bluePin, blue); 
// connection to pin and set blue value
delay(1500);
}