Level shifting problem

Digital

Linear

LMV321 Single supply OP Amp
and
TL331 Comparator







Edit

FYI