How to know where to put the threshold signal of an op-amp comparator
It's easy.
If VIN+ &gt; VIN- the output switches high.
To reverse the output logic levels just switch the inputs.
Don't forget your op-amp decoupling capacitor across the supply pins.