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?


  • 2
    \$\begingroup\$ Describe the two receivers of the signal and what is transmitting it and what is gating whether it goes to just one receiver or both? Is the transmitter an I/O pin? (I assume the gating is controlled by an I/O pin.) And what are the two receivers, really? (I don't want you to tell me that an LED is equivalent. I don't trust that assertion. I want to know exactly what is being driven.) \$\endgroup\$
    – jonk
    Jul 5, 2018 at 21:44
  • 1
    \$\begingroup\$ @Tony: Are you sure you've understood the OP's intentions. If TXD goes low LED1 will turn on. LED2 will turn on if the NPN is turned on (T0 high). I would connect R3 between the base and T0 rather than as shown. \$\endgroup\$
    – Transistor
    Jul 5, 2018 at 21:44
  • \$\begingroup\$ Actually you don’t need a transistor and just everything in series between 3.3V $ 0V and drive the midpoint using say Red Hi and Yellow Lo with (3.3[Vdd]-2.1[Vf] and 100 Ohms for each LED \$\endgroup\$ Jul 5, 2018 at 21:51
  • 1
    \$\begingroup\$ Mike, those 3 schematics all work. \$\endgroup\$
    – Henry Crun
    Jul 6, 2018 at 0:42

1 Answer 1



simulate this circuit – 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


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.