I have a bicolour RG LED, which looks like this:


I don't have a datasheet for it. There are three cables on it: one is cathode of each colour (common cathode type) and the other two are the anodes of each colour. The forward voltage of each LED is 24V, and forward current is 10 mA.

I want to change its colour by changing ONE digital output of an arduino. I mean that when the digital output is low, green LED is on, and red LED is off. And then when the output is high, green LED should be off, while the red LED is on. Digital output level is 3V DC when it's "high" state, and "0" V DC when it is "low" state.

So, how can I control which LED is on, while changing one digital output?

  • 2
    \$\begingroup\$ What do you think would solve this? This can be solved very easy with boolean algebra. \$\endgroup\$ Nov 27, 2017 at 21:43
  • \$\begingroup\$ Well, you could wire it so when it has power it is always green, and then under control of the one arduino output, change it to yellow, but this is probably not what you wanted. In short, with only one output, not even charlieplexing can help you here. \$\endgroup\$
    – Glen Yates
    Nov 27, 2017 at 22:36
  • \$\begingroup\$ @GlenYates a good alternative, but as the answer shows, it's possible with a single output. \$\endgroup\$
    – Passerby
    Nov 27, 2017 at 23:55

2 Answers 2



simulate this circuit – Schematic created using CircuitLab

Figure 1. High-side driver and inverter.

How it works:

  • If GPIO is low then Q1 is off and Q2 is off. Q3's base will find a path to ground through R1 and D1 and will turn on lighting D2.
  • If GPIO is high then Q1 is on, Q2 is on and D1 will light. Since the collector of Q2 is pulled high Q3's base current will fall to zero and D2 will turn off.
  • By using PWM (pulse width modulation) the light can blend from one colour to the other.

Does it have to be so complicated?

enter image description here

Figure 2. High-side driver fail.

Yes. Without the NPN transistor of Figure 1 there are two problems:

  1. There is a sneak path for the current through the protection diodes of the micro's GPIO. Whether the output is pulled high or tri-stated to try to shut off the PNP transistor of Figure 2 the base can turn on via D1.
  2. The high voltage - 24 V in your case - may damage the GPIO.

Opto-isolator option:

enter image description here

Figure 3. A pair of opto-isolators simplifies the task further and can isolate the 24 V circuit completely from the micro.

  • When the GPIO is low the upper opto-isolatore will be turned on.
  • When the GPIO is high the lower one will be turned on.

The very simple option:

The LED series resistors are clearly visible heat-shrunk in leads of the lamp. If you are prepared to replace these the circuit becomes trivial.

enter image description here

Figure 5. Direct drive of the LEDs.

Setting R1 and R2 to 56 Ω should be fine.

If the output is tri-stated (wired as an input or disconnected by program control) a current will flow through R1, L1, R2, L2 and both LEDs will glow dimly. On a 3.3 V device the voltage wouldn’t be high enough to illuminate both LEDs significantly so they would appear dark.

  • 1
    \$\begingroup\$ Looks like there is only one low side resistor \$\endgroup\$
    – Passerby
    Nov 27, 2017 at 22:39
  • \$\begingroup\$ Sure. Looks like it could use a pull up between q1 and q2. \$\endgroup\$
    – Passerby
    Nov 27, 2017 at 22:55
  • \$\begingroup\$ I've seen the pull-ups used before but never understood the risk without the pull-up on the base. Can you explain. \$\endgroup\$
    – Transistor
    Nov 27, 2017 at 22:57
  • \$\begingroup\$ @Transistor Without it, there's no DC path to completely tie base and emitter (unless you want to call the PN junction a DC path.) There's charge storage, remember? Also, it's also for speed due to that charge storage. And it's high impedance otherwise and can be affected by things like "touching it." See: Why pull base of BJT switch?, for another's perspective. I use them. They are cheap and effective. \$\endgroup\$
    – jonk
    Nov 27, 2017 at 23:06
  • 1
    \$\begingroup\$ I would go with the opto-isolator solution. Nice and clean. +1 on that one. \$\endgroup\$ Nov 28, 2017 at 3:00

I'm not sure if I understood your question correctly, but if I did, then the easiest answer is to use a not gate.

Take the output from the Arduino pin, tap into the output using a not gate, and then connect the two LEDs.

When the output is high, the LED connected directly to the output lights up while the other one doesn't. When the output is low, the LED connected to the not gate lights up while the one connected directly to the output doesn't.


  • \$\begingroup\$ While this would work, it would seem to require the gate, and 4 transistors, a NPN driver for a PNP transistor, due to the voltages involved. \$\endgroup\$
    – Passerby
    Nov 28, 2017 at 5:54
  • \$\begingroup\$ @Passerby, true. However, instead of using transistors directly, I would reccomend using it in the form of a solid state relay. \$\endgroup\$
    – Paddy
    Feb 5, 2019 at 1:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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