You need to implement a comparator circuit with hysteresis, and you pull up some app notes. They look something like this, credit to Analog Devices:

comparator schematics

If you have a circuit in hand, there are a dozen or so discussions online to determine the comparator’s characteristics: high threshold $V_{TH}...

Continue reading...