The diagram is a minimum example
R1 is the series resistor for the optocoupler's LED.
R2 is a pullup that's absolutely required there for other components.
enter image description here

  1. Will the pullup be overcome by the ground on the other side of the LED, pulling the digital pin to ground?
  2. If answer 1 is no, will the pullup current activate the LED?
  3. If answer 2 is also no, will this portion of the circuit operate properly, passing power from pin 4 to 3 based on the state of the digital pin?

4 Answers 4


Probably quicker to wire it up and measure but I'm guessing that

  1. Yes, due to the values, the weak 10k pull up will be overwhelmed by the stronger pull down via the led. While it's still only a few hundred microamps, the 10k/1.?k resistor pair is a voltage divider and will result in about 0.45V at its output. The .? Is the led "resistance" per say but due to the much smaller resistor it can be ignored, and this is for an unloaded midpoint. A high impedance GPIO input would essentially be unloaded.

  2. Yes or no the led will be forwarding some current but based on that PC817 datasheet the forward voltage is so low that the forward current is outside the listed graph. So its hard to tell how much if any the led will light up.

  3. If you add in the digital output as on or off, it will take the opto out of the unknown behavior state to the hard on or hard off state.

So the real question is why do you have the pull up?

  • \$\begingroup\$ Thank you for your answers. The pullup is required for one of the inverters in the larger circuit. I'm doing my best to isolate individual issues instead of tossing the whole circuit up and asking for others to finish it. It's a 3LED circuit to show the state of a digital pin. \$\endgroup\$ Commented Sep 6, 2021 at 12:10
  • \$\begingroup\$ @mike that's tying our hands behind our back \$\endgroup\$
    – Passerby
    Commented Sep 7, 2021 at 1:16
  • \$\begingroup\$ Not trying to leave things unanswered, but I am trying to do for myself and just focus on one small issue. You have answered the questions I asked, and I thank you, and I need to look at another approach. In 3 attempts using FETs I end up with an intersection of a pullup and a pulldown. \$\endgroup\$ Commented Sep 7, 2021 at 13:22

If you insist on the logic shown and cannot reverse it as @Rohat’s answer shows, you can leave the pull-up and add a MOSFET such as a 2N7000 or 2N7002 to drive the optocoupler LED. Image from here:

enter image description here

R1 would be something like 1K in your case, assuming you want the LED current to be in the 3.8mA range.

The MOSFET gate will not load the output other than a bit of capacitance and will allow the pull-up to work.

The way you have shown it, the “digital pin” voltage will either be close to 5V with the pull-up having no effect when high (a low impedance output) or roughly 1.5-1.6V because of the loading of the LED with the output tri-stated. That will also result in an LED current of a few hundred uA which may or may not be interpreted as “on” depending on the circuit at the other side, the optocoupler characteristics, the temperature, etc, probably a situation you want to avoid.


Instead of answering your questions one by one, I'd like to approach your problem from a different aspect.

In the configuration shown, if you leave the Digital_Pin unconnected (e.g. open drain) the LED current will be ~0.3mA. We don't know which CTR rank is chosen, so we don't know if the respective collector current will be sufficient for your application. Plus, this will affect the frequency response of the OC. So you may not be able to use this OC at some frequencies (e.g. RS-485 isolation or driving something with PWM).

If the Digital_Pin is configured as push-pull then the 10k pull-up resistor becomes completely meaningless:


simulate this circuit – Schematic created using CircuitLab

... because when the Digital_Pin outputs 1, the pull-up resistor will get shorted.

The following may be a better configuration:


simulate this circuit

With the configuration above, you can configure the Digital_Pin as open-drain and use the pull-up always. If you leave the Digital_Pin unconnected or logic-high, no current will flow through OC's LED. If you pull the pin to logic-low, the current determined by RLED will flow.


There is no way to answer the question without knowing two more pieces of information.

1 - How is the digital line characterized. When low, how much current will it pull. When high, what is its nominal voltage, and how much current can it supply at that voltage? For instance, is it a CMOS active output which goes from ground to +5? Or is it an open-collector circuit which drives to ground? Or is it something else?

2 - What does the circuit which connects to the opto output look like? What impedance, and what threshold do you need to drive?

Until you provide the answers, you can't get any.

  • \$\begingroup\$ The digital pin is connected to an Arduino (328 or 2560). It will be high of 5V, low of 0, and potentially high-z. Opto output side drives a MOSFET inverter circuit, specifically it connects to both gates of an N-MOS and a P-MOS (little SOT-23 signal MOSes). I do not have an impedance. \$\endgroup\$ Commented Sep 6, 2021 at 3:12

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.