Switch polarity on LED
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.



simulate this circuit &ndash; 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.

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.