Enable one or two of the same output via switch (minimalist schematic)
simulate this circuit &ndash; Schematic created using CircuitLab

Fig1: D2 current sinks into TXD only when enable=1. Your original schematic was missing a base resistor R3, so the enable pin would try to drive directly into the txd pin through the base of the transistor.

Fig2: Current can only flow through D2 when ENABLE=high and TXD=low. Any other combination there is not current through D2

Fig3: If enable is low, D2 current can flow through Q1 into Enable ONLY if Q1 is on - ie. TXD is low.



This is a different arrangement. Port pins can only supply limited current, and you can drive 100mA into IR leds.







simulate this circuit

In this case Q1 switches all D2 current while Enable is an input. Setting Enable=1 holds base high, blocks Q1, D2 stays off