I wanted to use a RGB led with arduino. I programmed it that it should change colour in one second 1st red, 2nd green, 3rd blue. But it is showing only red.
Circuit connection:
RGB gnd (long leg) to arduino GND
RGB 1st pin (Red) to arduino 9 using 220ohm resistor
RGB 3rd pin(Green) to 10 using 220ohm
RGB 4rd pin (blue) to 11 using 220ohm
Code
int red = 9
int green = 10
int blue = 11
void setup()
{
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
}
void loop()
{
digitalWrite(red, HIGH);
delay(1000);
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
delay(1000);
digitalWrite(green, LOW);
digitalWrite(blue, HIGH);
delay(1000);
digitalWrite(blue, LOW);
}