Make the reference
30 kΩ over 20 kΩ gives 2 V from 5 V.
Build a basic LM311 circuit with labeled pins, component values and connection guidance.
Separate emitter return, reference divider and collector pull-up.
Follow the component values and pin connections
30 kΩ over 20 kΩ gives 2 V from 5 V.
Ground pin 4 for power and pin 1 for the output transistor. Add 100 nF supply bypass.
Add 10 kΩ to +5 V at pin 7. VIN below 2 V gives LOW; above 2 V gives HIGH.