Electronic – Input circuit for GPIO of a 3.3v tolerant microcontroller

comparatorgpio

The micro controller I'm using detects Low for 0-1.8v and high from 1.9-3.3v.

The level I need to check is if the input if from 0v-5v stay low, 5v-24v go high on the micro-controller pin( above 1.8v).

I cannot use a Voltage divider here as the high range has to work from 5v till 24 while giving an output of 2v-3.3v.

I tried using a basic comparator circuit but here the output becomes Vcc. I need the output to become 2v-3.3v.

Output State needs to be digital and not analog.
EG:
0-5v should be LOW and 5v-24v should be HIGH

I have a 3.3v power source for the micocontroller.

How could this be achieved?

Reference attached for comparator.enter image description here

Best Answer

Use an open collector comparator like a LM339..

schematic

simulate this circuit – Schematic created using CircuitLab