The comparator solution as drawn (both of them) require a split power rail. Otherwise the +ve input is never going to be able to go below the -ve one to switch the comparator.
For a single rail solution:-
It is better if the -ve input is wired to a mid point between +5V and ground provided by a potential divider of two equal resistors, of say 10K.