/*
RGB LED_BUILTIN
*/
int redPin = 11;
int greenPin = 10;
int bluePin = 9;
int redPin1 = 3;
int greenPin1 = 5;
int bluePin1 = 6;
//uncomment this line if using a Common Anode LED_BUILTIN
//#define COMMON_ANODE
void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
pinMode(redPin1, OUTPUT);
pinMode(greenPin1, OUTPUT);
pinMode(bluePin1, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
setColor(255, 0, 0); // red
digitalWrite(LED_BUILTIN, HIGH); // turn the LED_BUILTIN on (HIGH is the voltage level)
delay(1000);
setColor(0, 255, 0); // green
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
setColor(0, 0, 255); // blue
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
setColor(255, 255, 0); // yellow
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
setColor(80, 0, 80); // purple
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
setColor(0, 255, 255); // aqua
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
setColor(80, 80, 0);
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
setColor(80, 60, 10);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
setColor(10, 40, 60);
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
setColor(40, 0, 220);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
void setColor(int red, int green, int blue)
{
#ifdef COMMON_ANODE
red = 255 - red;
green = 255 - green;
blue = 255 - blue;
#endif
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
analogWrite(redPin1, red);
analogWrite(greenPin1, green);
analogWrite(bluePin1, blue);
}
Comments