I'm making a PCB and my real estate is limited.
I am using an AT89C2051 microcontroller, and it only has one serial transmit output.
What I need is a way to set whether the output from the serial transmit pin is sent to only one common-anode device or to two common-anode devices simultaneously. To make things simple, let's make the LED's with resistors in series as the devices in question.
So far, the R2 and LED1 in series where its connected is OK since that's the one device that always shows the data transmitted from the microcontroller.
Because I'm using the standard UART data format, I'd like a pin on the micro (Pin P3.4 in this example) to decide whether LED2 should stay logic high (light off), or LED2's response should match LED1's response.
I'm not sure if I hooked up the transistor the right way for this functionality or if I should use PNP instead?
I added a resistor (let's say 10K) to the NPN base because I needed something strong enough to make the NPN base as logic high if the micro doesn't set the pin as logic low.
To answer a comment, I'll explain...
In reality, the receivers are IR emitters which function like an LED so I used LEDs as an example. The IR emitters are already fitted on a separate board common-anode style (meaning all anodes of the IR emitters are connected to the VCC line)
The separate GPIO pin (P3.4 in this example) is controlling whether LED2 is following the signal of LED1 or just stays logic high.
As for Henry Crun's answer of three schematics, I can explain further.
Left-most schematic won't work for me because the "D2 enable" controls whether the light is only logic high or logic low. There is no way to make D2 in that circuit to either follow the value of D1, or to make D2 off.
Middle schematic won't work for the same reason.
Now could the Right-most schematic work? hmm... maybe someone can explain it more?