Actually what you describe would be accomplished with a comparator.
However, a Schmitt trigger is a better option because it will not switch rapidly back and forth when the signal is at or very close to 2V.
For your case a comparator with a small amount of hysteresis (there's some words to Google with) would form a schmitt trigger that may solve your problem.