4V - 5V signal on Digital Input

We have an input signal that is at 4V when it is low, and at 5V when it is high. How could we bring the voltage down so that we can read it in as a digital input?

And no, analog inputs are not an option :smiley:

The first thing that comes to mind is a simple level triggering opamp circuit? For example LM339s or LM139s? Set up a resistor divider so that 4.1v is Vref, apply your 4v-5v to Vin, Vout should be ~0v if Vin is less than 4.1v and ~5v is greater than 4.1v…

See National Semi AN-74.pdf application note for more info.

Do you mind my asking why analog inputs are not an option? Are you already using all of the analog inputs on the controller?

If you need to use a digital input, the suggestion of using an LM339 (4 comparators in a package) or an LM393 (2 comparators in a package) is a good approach.

Data sheets can be found online:

Thanks guys, I’ll look into those options. The only reason we don’t want to use analogs is because we’re really just looking for on vs. off, and the additional sampling required for using an analog input is overkill.

It may be overkill, but if the custom circuit’s output does not operate such that it meets the designed parameters of the RC, then you need to adjust your approach.
An analog comparison will only take a couple lines of code.

{
char a;
{
if (Get_analog_01() <= 800)
{
a = 0;
}
else
{
a = 1;
}
}

Building custom circuitry, when the an analog input can get your
on-off state is overkill. We ran out off digital inputs this
year and needed one more. We wired the switch to a
pullup resistor and an analog input, coded to set a variable to 0 when
the voltage was below 2.5 volts and to 1 when the voltage was
above. It worked just fine.

Eugene