I am learning electronics so this is learners question. I wired up the LM339N quad voltage comparator (powered using a 5v power supply through a current limiting resistor of 40 ohms)-in a straightforward standard way- like at


but for the potential divider I used two 4.7k resistors-not a pot- and I only used one comparator. I also had an output LED too.I added the standard 0.1uf capacitor near the power supply. So the circuit worked as it should (for the input voltages to the comparator I used AA batteries that went through a current limiting resistor of 500 ohm into the comparator input) at 1.5 volts or less the LED turned off. At higher input voltages the LED turned on.

I want to replace the LED with a pc123 optoisolator, so the optoisolator behaves like a switch (just on or off, with a resistance of between 1 and 60 ohms when on, or zero ohms when off)-so what is the circuit to do this? So when the opto is off there is no resistance .

There maybe other components (im not sure of this) required in addition to the pc123 for answering this question . I replaced the led with a pc123 optoisolator but smallest resistance I could get (directly from the phototransistor) out of it was between 5k ohms and 6k ohms and I used a 40 ohm resistor for limiting the current into the opto. If its not possible to get between 1-60 ohms , then whats the the best that can be done to control the output resistance?

here is data sheet for the opto


Also, for a different and related circuit, I want to replace the LED with a bc547 transistor to turn on a 5v relay -so what is the circuit to do this?

I dont need a fancy answer. I want an answer that show clearly how to answer the question using those components in a minimal way.

Come on folks, try and answer the question!

  • 1
    \$\begingroup\$ Just because a lot of articles say a transistor can be used to switch it is not a switch. If I had a (mechanical) switch with an 'on resistance' of between 1 and 60 Ohms I'd throw it away as broken. \$\endgroup\$ Dec 31, 2016 at 20:16
  • \$\begingroup\$ If im right-some mosfet's used as a switch have an on resistance of 1 ohms or more but less than 100 ohms \$\endgroup\$
    – Pete
    Dec 31, 2016 at 20:23
  • \$\begingroup\$ The problem with the "switch" view is that the resistance from source to drain (or collector to emitter) depends on a voltage (or current) elsewhere, which is also affecting the transistor. If you tie the emitter or source to ground, then it becomes easier to analyze the transistor as a plain old switch, but generally speaking, you can't just swap one for the other. \$\endgroup\$
    – Dave M.
    Dec 31, 2016 at 20:25
  • 1
    \$\begingroup\$ To address your opto question, it may be more useful to look at the device or circuit that you want to control with the switch. If you don't know, and you really do need an on/off switch, then you may have to put in an actual physical switch, in the form of a relay. Then, you'll know that the opto has to control the coil of the relay, and you can design accordingly. \$\endgroup\$
    – Dave M.
    Dec 31, 2016 at 20:28
  • \$\begingroup\$ Yes that same as my second question . Disadvantage of relay is switching speed. \$\endgroup\$
    – Pete
    Dec 31, 2016 at 20:32

1 Answer 1


You cannot change the characteristics of the transistor inside the optoisolator. If you need to switch more current than it can handle (and you need the isolation that the opto provides), then you will have to use the opto to drive a larger transistor that can switch the load you have.

Measuring the "resistance" of a transistor C/E junction is not meaningful.

That part of your question, as posed, cannot be answered.

As to the second part -- if you want to switch a relay with the output of the comparator using a small NPN transistor is a fine choice.

Consider that you are going to want to use active-high output from the comparator in that case, so you will need to reverse the sense of the inverting and non-inverting inputs to the comparator. Simply drive the base of the BC547 through a suitable current-limiting resistor. Keep in mind - the maximum collector current is rated at 100 mA - just like with the photocoupler above, you're going to be limited how large a load you can switch with such a small device.

  • \$\begingroup\$ I tried your suggestion for switching a relay and it uncovered a new problem. Rather than turning the relay on the relay buzzes (turn on or off rapidly) instead of being constantly on. But it works properly as expected when off. I suspect this is because when led is on it flickering on or off rapidly and gives the optical illusion of being constantly on. So how to fix this and what is causing it? \$\endgroup\$
    – Pete
    Dec 31, 2016 at 21:41
  • \$\begingroup\$ Is the relay actually switching any load at this point? Without seeing the actual schematic of what's in front of you, it would be impossible to speculate further. Take a few minutes to add a schematic to your question. \$\endgroup\$ Dec 31, 2016 at 21:50
  • \$\begingroup\$ Yes it clicking loudly on and off and switching.The relay isnt switching anything on or off on its high voltage side. \$\endgroup\$
    – Pete
    Dec 31, 2016 at 21:52
  • \$\begingroup\$ I dont think it needs to switch anything on or off on its high voltage side- as I dont think the problem originates from there \$\endgroup\$
    – Pete
    Dec 31, 2016 at 21:54
  • \$\begingroup\$ I also noticed the led does flicker with certain voltage inputs , with no relay just using the schematic given in the link (with the monor differences mentioned) \$\endgroup\$
    – Pete
    Dec 31, 2016 at 21:58

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.