1
\$\begingroup\$

I have RGB LED(s) similar to the the 5mm in the pic. I have had success in uploading the example Blink program and testing it with a single LED connected to pin 13 of my Arduino Nano/ATMEGA328.

The LED timing is correct as per the program - One second OFF and One second ON - however, the colors are emitted at random.

Is there someway I can programmatically instruct the LED to display particular color at particular point of time. For example, first emit only Blue, then Red and so on.

Here is the code (its standard example with Arduino IDE):

int led = 13;
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}
\$\endgroup\$
  • \$\begingroup\$ An RGB LED with only two leads, are you sure? You'll have a much better chance at getting useful answers if you copy in the code you use to drive the RGB LED. \$\endgroup\$ – jippie Aug 10 '12 at 8:17
  • \$\begingroup\$ Yes it has only two leads - similar to the one in start of this video. I have added the code. \$\endgroup\$ – WeaklyTyped Aug 10 '12 at 8:23
  • \$\begingroup\$ I share jippie's doubts. With two leads the best you can do is place 2 LEDs in antiparallel. With two different LED colors you can emulate a third color by fast switching between the two, giving you three colors. But not RGB. \$\endgroup\$ – stevenvh Aug 10 '12 at 8:27
7
\$\begingroup\$

I assume you have one of those LEDs that include a small chip that does the blinking? In that case there is no way you can reprogram that chip.

enter image description here

If you want the color to be under your control use a four-legged LED with separate connections for the three colors.

\$\endgroup\$
  • \$\begingroup\$ I have found a video of a similar LED and I have posted the link to the video as comment to the question. Any how, you seem to be correct. \$\endgroup\$ – WeaklyTyped Aug 10 '12 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.