I have wired up the LM311 circuit shown in the figure below. It should work as follows (at least to my understanding), when V+ (pin 2) > V- (pin 3) the output (pin 7) should rise to 12V and when V+ < V- the output should fall to Gnd. I have applied a 1kHz square with an amplitude of 1V swinging around Gnd to pin 2 (V+), see scope image on the second picture. I expect a square wave from 0V to 12V on the output but instead it stays at approximately -12V (CH2 on the scope image), so i.e. at Vee. Even when I apply 12V on pin 2, the output stays at -12V.
Go over your connections on the hardware and make sure they are connected to the right pins/ wires/ components/etc.
I’ve connected everything together with a circuit I worked on and thought everything was fine, then the circuit is misbehaving. Two hours later I find out a resistor is connected to the wrong pin, changed it and everything was fixed!