/* Full Color Led Control by Connecting Common Anode Pin, and use PWM
*/
//define the pin color
const int redPin=9; // definition of Red LED Pin
const int greenPin=10; // definition of Green Led Pin
const int bluePin=11; // definition of Blue Led Pin
//Timer
int Timer=500; //timer amount
//Function to change color using RGB values
void setColor(int red, int green, int blue){
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}
void setup() {
// put your setup code here, to run once:
pinMode(redPin,OUTPUT); // set the red Led Pin as output mode
pinMode(greenPin,OUTPUT); // set the green Led Pin as output mode
pinMode(bluePin,OUTPUT); // set the blue Led Pin as output mode
}
void loop() {
setColor(0, 255, 255); // Red
delay (Timer);
setColor(255, 0, 255); // Green
delay (Timer);
setColor(255, 255, 0); // Blue
delay (Timer);
setColor(0, 0, 255); // Blue
delay (Timer);
setColor(255, 0, 0); // Blue
delay (Timer);
setColor(0, 255, 0); // Blue
delay (Timer);
setColor(0, 0, 0); // Blue
delay (Timer);
}