How to make the LM339 IC source current on its output pins instead of sinking current?

I know that the LM339 Comparator IC has a current sinking output. I made a small night lamp with the help of a LDR and an LM339 comparator IC. It worked properly.

The LDR connected to the inverting input (pin 4) of the IC and a reference voltage was supplied at the non-inverting input (pin 5) from Vcc through a resistor. This way the comparator compares the value of the LDR with the reference voltage and sets the output accordingly.

But, then I wanted to replace the LED with a transistor since I wanted to do more than just toggle LEDs. I tried to implement the transistor in my circuit like this, but it still does not work:

I just implemented a part of it (not the switches and all. I have my LDR in place of that) in my own circuit which uses an LDR. Its taken from an answer on another thread. That entire answer can be found here: https://electronics.stackexchange.com/a/283533/127782

I realize that in order to turn on the transistor I need a current source from the output pins of the LM339. How would I achieve that ? If that's not possible, or I have misunderstood something, can you just tell me how to operate the transistor in this circuit ?

Thanks.

• I had updated the answer in the previous question, added a potential divider to the V-, hope it now works as expected, use a PNP transistor at output stage to source current to load
– Raj
Feb 5, 2017 at 7:51
• To turn on an LED as shown the comparator is not needed (unless this is a learning exercise). |. Remove 10k, U1, 4.7k. | Connect the 10k from switch right side to Q1 base. If available a 100k from base to ground may sometimes be useful. Not usually needed. Feb 5, 2017 at 12:01
• You've got a current source, the 4.7k resistor, that should be plenty to saturate the transistor when the 339 is not sinking current. That circuit should work unless you've connected it incorrectly, with a logic inversion of course! Feb 5, 2017 at 12:41
• What does "to no avail" mean? Feb 5, 2017 at 20:58
• I have updated the question @BruceAbbott. By no avail I meant it did not function. Feb 6, 2017 at 13:52

modified circuit to use PNP transistor

If open circuit condition is making issue (when the output is not sinking), use the 4.7k pull up as in your circuit

updated the circuit based on the comment by @Paul Elliott

• It would be good practice to add a large resistor (100K or so) between Q1 base and emitter, to make sure that leakage current doesn't keep the transistor from turning completely off. Feb 5, 2017 at 16:45
• updated the circuit including 100K
– Raj
Feb 5, 2017 at 16:57