3
\$\begingroup\$

I have an LED (don't know the part number unfortunately) that lights up red when its anode is tied to Vcc and its cathode to Gnd, and when the polarity is reversed, it lights up green (opposed to some common cathode LEDs that have multiple anodes, this one has only 2 "legs") The LED has a forward voltage of 1.8V, so I calculated a current limiting resistance of 330 ohm (about 10mA)

I'd like to make a transistor equivalent of this circuit:

schematic

simulate this circuit – Schematic created using CircuitLab

I came up with this circuit:

schematic

simulate this circuit

When A is tied to Gnd, the LED lights up green (as expected), but when I pull A high (at Vcc) the LED is not lit. I measured the emitter voltage at Q1, and it is about 3.3V. Same goes for Q2's emitter, but in both cases. I don't quite understand why the emitter voltage doesn't drop to 0V (I used this question's answer as inspiration). Am I missing some extra resistor somewhere? (or is this not the recommended way to switch polarities?)

Thanks in advance

\$\endgroup\$
3
  • 2
    \$\begingroup\$ Is that drawn correctly? Q2 never turns off because the collector and base are both tied permanently to Vcc. \$\endgroup\$ Oct 10 '20 at 12:29
  • \$\begingroup\$ What is driving 'A'? \$\endgroup\$
    – Transistor
    Oct 10 '20 at 12:31
  • \$\begingroup\$ @Transistor 'A' is connected to a digital output pin of an Arduino, so it should be either 0V or 5V \$\endgroup\$
    – vandebrug
    Oct 10 '20 at 12:35
3
\$\begingroup\$

If you want to drive a load like that differentially, a pretty energy efficient way of doing that is with a H-Bridge. Here is what it might look like if you did it with BJT’s (assuming you have p-channel BJT’s around):

enter image description here

This would be much easier to accomplish with MOSFET’s, as you wouldn’t need so many resistors, and it would look like this:

enter image description here

If you are more digitally inclined, and/or have some logic IC’s around (could be done with a single 74HC04 Hex-inverter), you could also make that same circuit as follows:

enter image description here

\$\endgroup\$
7
  • \$\begingroup\$ Your answer solved my problem. Although I like Transistor's simple solution using a voltage divider, I believe my question could be rephrased as "what am I missing to construct an H-bridge?". I've read some about this concept (and it turns out the "complex" examples using a motor did supply me an answer, I just couln't apply it it to lighting up an LED) \$\endgroup\$
    – vandebrug
    Oct 10 '20 at 14:52
  • \$\begingroup\$ Glad to hear it! Just a heads up, Spero Pefhany’s circuit is effectively doing the same thing as well, so if you don’t have the hex-inverter, you could accomplish the same thing with op-amps / comparators as he has shown. As far as which is more effective, it would come down to the difference in cost / power-consumption. \$\endgroup\$ Oct 10 '20 at 14:56
  • \$\begingroup\$ If you have 2 GPO pins available, you can of course just connect the led in series with a 330R resistor between them. The drive one or the other high (and the other low) to select the colour, and both pins either high or low to switch off. \$\endgroup\$
    – Dan Mills
    Oct 10 '20 at 23:46
  • \$\begingroup\$ @KevinSullivan Could you explain why the NPN transistor on the bottom right is needed? I figured if the PNP and NPN transistors on the right hand side of the LED are swapped vertically, the circuit would behave the same, or am I wrong? \$\endgroup\$
    – vandebrug
    Oct 11 '20 at 7:24
  • \$\begingroup\$ @vandebrug I was kinda going for operating all of the BJT’s in their fully-on region, because otherwise there will be a voltage across them while the conduct, and dissipate power. This power will probably be negligible at this current level, but I personally just like to do things that way for switching applications. \$\endgroup\$ Oct 11 '20 at 13:55
8
\$\begingroup\$

enter image description here

Figure 1. A simple (though inefficient) solution. Image source: 1 GPIO bi-colour 2-pin LED.

  • When GPIO is low R1 provides current to L2 and the indicator glows red.

  • When GPIO is high current flows through L1 and R2 to ground and the indicator glows green.

  • By alternating the GPIO high-low fast enough both LEDs can be illuminated giving an orange colour (since they’re both in the same package). By varying the ‘on’ pulse width a smooth cross-fade can be given from red to green.

  • If the GPIO is tri-stated (disconnected) the LED will be dark.

Note that this circuit is not very efficient. R1 and R2 pass current to ground always and when the red LED is on R2 is stealing power from it and when the green LED is on R1 is stealing power from it. It may take some experimentation to get this to work nicely with your LEDs.


Your first schematic is a low powered heater. With switch up R2 and R4 are powered and warm the environment with maybe a hundred mW or so. With the switch down R1 and R3 do the same thing. The LEDs will never light as both sides are grounded.

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 2. A modified version of your first figure.

This lights one LED but also wastes power as heat in the resistor connected between Vcc and GND. At least you'll get some light.

enter image description here

Figure 3. OP's second circuit.

This has the major problem that Q2's base is tied to Vcc so it will never turn off.

\$\endgroup\$
1
\$\begingroup\$

Here's one way of doing it, using an LM358 dual op-amp and a few resistors:

enter image description here

\$\endgroup\$

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.