Getting the output pin of the LM311 comparator IC to do anything was a head scratcher for me until I saw this website that shows the simplified internal organization of the LM311:
https://diyodemag.com/education/the_classroom_the_lm311_voltage_comparator
The output pin, pin 7, is NOT the output of the op-amp inside the LM311. The output of the op-amp inside the LM311 is connected to the base of an internal NPN transistor. The collector of the transistor is connected to pin 7. The emitter of the transistor is connected to pin 1. When the voltage on the inverting input (pin 3) is higher than the voltage on the non-inverting input (pin 2), the internal op-amp sends an output current to its internal output.
That internal output of the op-amp is connected to the base of the NPN transistor and turns on the NPN transistor.
That let's a current flow from pin 7 (the "output" pin - badly named), through the transistor, to pin 1, the "ground" pin. Remember, the emitter of the transistor is connected to pin 1.
So, when the op-amp turns on, it basically flips on a "switch" between pin 7 and pin 1.
So, pin 7 is SINKING current. It is the collector of the internal NPN transistor which is acting as a "low side" switch. Connect a load to pin 7 and the load is connected to ground through pin 1 when the op-amp turns on.
The internal NPN transistor can handle up to 50 mA of current. So, for low current, single supply type projects, just connect the load to the positive supply rail and then connect the other side of the load to pin 7. Connect pin 1 and pin 4 to ground.
https://diyodemag.com/education/the_classroom_the_lm311_voltage_comparator
The output pin, pin 7, is NOT the output of the op-amp inside the LM311. The output of the op-amp inside the LM311 is connected to the base of an internal NPN transistor. The collector of the transistor is connected to pin 7. The emitter of the transistor is connected to pin 1. When the voltage on the inverting input (pin 3) is higher than the voltage on the non-inverting input (pin 2), the internal op-amp sends an output current to its internal output.
That internal output of the op-amp is connected to the base of the NPN transistor and turns on the NPN transistor.
That let's a current flow from pin 7 (the "output" pin - badly named), through the transistor, to pin 1, the "ground" pin. Remember, the emitter of the transistor is connected to pin 1.
So, when the op-amp turns on, it basically flips on a "switch" between pin 7 and pin 1.
So, pin 7 is SINKING current. It is the collector of the internal NPN transistor which is acting as a "low side" switch. Connect a load to pin 7 and the load is connected to ground through pin 1 when the op-amp turns on.
The internal NPN transistor can handle up to 50 mA of current. So, for low current, single supply type projects, just connect the load to the positive supply rail and then connect the other side of the load to pin 7. Connect pin 1 and pin 4 to ground.









