Complex analog to digital help.

i have a circuit that gives an analog output. it has 2 outputs. With a press of a button, the first output is 4.2v and the second is 0v, if i press the other button the first is 0v and the second is 4.2v. how can i convert this to a digital signal?

Those sound like digital signals already to me.

That is digital! :wink: There are only two states, ~0V and ~4.2V.

A quick look at the chip-specs (you might want to double-check this) says anything above 0.9V is a digital-high, anything below 0.3V is low.

well its not fixed :confused: if my input is for example 10v the output would be 10v and 0v or 0v and 10v, i want this to be a fixed 5v and 0v or 0v and 5v. Is this possible

Try a potential divider.

i have a circuit that gives an analog output.

Feel free to share

The circuit is a Rc receiver so its pretty complex, and i dont have the schematic. The outputs im talking about are the motors output that are driven by H-Bridges. the output voltage of these outputs depend on the battery, but i want this output confined to 5v and 0v,regardless of the input.

You might want to consider adding a zener diode to each output to limit it to 5v.

http://www.reuk.co.uk/Zener-Diode-Voltage-Regulator.htm

can i use a comparator?

can i use a comparator?

Only if you can find one that will let you use an input that is considerably larger than the supply voltage (you'd want to limit the supply to 5v so that the output is 0-5v - otherwise you'd still be in the same boat as before), and I don't know of any.

Oh! that explains why my comparator circuit isnt working...I can also limit my output to give 3.3v and 0v, so will this work with a comparator with a supply voltage of 5v and a input of 3.3 volts?

If you can limit your output to 3.3v, why do you even need the comparator? 3.3v is within the "high" band for a digital input.

A quick look at the chip-specs (you might want to double-check this) says anything above 0.9V is a digital-high, anything below 0.3V is low.

Yes, you really do want to double check that.

Here's the page from the datasheet:

At the 5V the Arduino runs at, Low is -0.5 to 0.3V, and High is 0.6V to 5.5V.

Anything outside those ranges is either an invalid value (0.30000000000000000001v to 0.59999999999999999v), or liable to blow the chip up.

No, high is 0.6 times Vcc.
If Vcc is 5volts, then a high must be 3volts or more.

Oops, misreading there... You're right, and when you're right, you're right :wink:

Low is <= Vcc * 0.3, and high is >=Vcc * 0.6. At 5v, that equates to <=1.5V and >=3V.

The best and simplest is to use a 5R1 1/4 watt Zener diode, input to cathode and anode to ground and a 1K series resistor from cathode to device input free end is now a 'protected input', anything less than 5V won't cause the diodes to conduct, they'er great for 'accidental' Neg voltages and will draw 5 mA from the 10V signal (need a little minimum current for the zener). inexpensive, put them on the shield. IMO

Doc

If the voltage you are monitoring is always 3v or above in the high state, simplest solution is to connect it to the Arduino input pin through a sufficiently high value resistor, e.g. 47K or 100K. The microcontroller internal protection diodes will limit the voltage to a safe value, and the resistor will limit the current flowing through the protection diodes to a value that does not interfere with the operation of the chip.