GP2Y0A21YK0F Infrared Distance Sensor and LM393 dual comparator

Hi Friends,

I am trying GP2Y0A21YK0F Infrared Distance Sensor for detecting movement for two directions, Let’s suppose Left and Right. I am using two GP2Y0A21YK0F sensor for this purpose. It is working fine If I take analog readings and process that data with Arduino Nano.

I wanna convert this analog reading to Digital one to be used as digital input to trigger an interrupt function. For this purpose I am trying LM393 dual comparator. Schematics of How I have connected all the hardware is attached.

When there is nothing in front of sensor, It gives voltage of 0.18-0.20v on multimeter and it’s value may increase to 0.5-0.8 volts if an object is in front of sensor. I have set the reference voltage for LM393 at 0.35v, as I want 0 signal (LOW) as output if the voltage across analog pin of sensor exceeds 0.35 volts which is adequate for sensing movement of an object from one direction to other within range of 2.5 feet.

My problem is, LM393 returns 0.30 to 0.60 volts across it’s output pin when there is an object in front of sensor (I have connected Red wire of multimeter with +5v and Black wire to output pin of LM393) while it should give 0 volts as being connected to ground.

Moreover, this output value fluctuate 0.05-0.1 volts and I cannot set the interrupt for Rising or Falling.

May someone helps me?

  1. Your schematic seems to be incomplete. There are components with no wires connected and there are also several signals unidentified.

  2. I think you are using the comparator incorrectly. First, you should connect the reference voltage to the negative input rail (switch the connection of the inputs). Second, if you take a look at the datasheet, you would notice that you need a 3K ohm pullup resistor on the output of the LM393.

  3. Why is D0 only connected to a 10K pullup? Is it not connected to anything else?

  4. What is the second LM393 for? It's not connected to anything!

Here is the complete schematics.

Reference voltage is connected to negative input rail.

Moreover, 10K Pullup is already added to Output.

I had previously attached Eagle schematics, now I have simplified all the connection with wires.

Any body there to help me out? :(

Looks good to me. Did you try the new schematic out?

Yes I have tried this schematic, It runs very fine if I use one sensor, but When I combine two sensors of same setup and and connect their output to Arduino, both sensors become irresponsible and their output remains High (Output does not go to LOW when an object comes in front of any sensor).