I thought of creating a circuit for a light barrier. I got the required components: an IR LED diode, an IR phototransistor, an op-amp, a potentiometer, a blue LED, and resistors. After much testing and re-building I came up with this circuit which works well enough:
simulate this circuit – Schematic created using CircuitLab
Until I removed the multimeter I used for testing. After that, the phototransistor stopped turning on the LED when the beam of light from the IR LED was interrupted.
I thought the multimeter took some current from the circuit, and moved the threshold for the LED to turn on. I rotated the potentiometer to both sides (moved a few hundred millivolts and interrupted the light barrier, and then moved again) and the LED stayed either on or off, not changing its state when the beam was interrupted.
I can't test this unknown state, because when I plug in the multimeter it works again. I can't have a multimeter always on next to the circuit to make it work. There is probably some beginner mistake I simply overlooked.