Two IR sensors on same 5v and gnd not working

hi I am working on some kind of IR positioning system for my robot (youtube.com/watch?v=in5TRQQNgEA). I already built IR beacon, and now i need sensor that will approximately determine where IR beacon is. I bought two cheap ir sensors (38khz). When I tested one by one it worked fine but when I put together two i only get readings that both are on or off but I can't get one off and one on. I tried to completely cover one but still nothing. Both sensors share same gnd and 5v pin but everyone has it own digital pin for readings.

5v ------------------------------------------------ | | sensor1---digitalPin1 sensor2---digitalPin2 | | gnd-----------------------------------------------

is there any solution to my problem ?? please help me!

Code?

JimboZA: Code?

for now it is simple: int a = digitalRead(6); int b = digitalRead(7); Serial.print(a); Serial.print("-"); Serial.println(b); delay(100);

How are you ensuring that beacon A isn't detected by sensor B and beacon B isn't detected by sensor A?

tylernt: How are you ensuring that beacon A isn't detected by sensor B and beacon B isn't detected by sensor A?

I only have one beacon

\ 1 \ 2 / 3 / \ \ / / \ \/ / \ /\ / \ / \ / \ / \ / \ / \ / \/ \/


|sensor1| |sensor2 |

in theory if only sensor1 is true robot should move to left if both sensors are true it won't move and if sensor2 is true robot should turn to right

Do you have a link to the data sheets for these components?

wildbill: Do you have a link to the data sheets for these components?

i bought them on ebay so hard to find datasheet they are tsop1838t hope this is it http://www.digchip.com/datasheets/parts/datasheet/000/TSOP1838-pdf.php

Ah, I see. Do you have some kind of shield or baffle in place to make sure the right sensor can't "see" to the left and vice versa?

tylernt: Ah, I see. Do you have some kind of shield or baffle in place to make sure the right sensor can't "see" to the left and vice versa?

i have some small plastic between but i also completely cover one sensor but still could only get both on or both off :/

Probably need a pulldown resistor on each sensor pin.

5v ------------------------------------------------ | | sensor1---digitalPin1 sensor2---digitalPin2 | | gnd-----------------------------------------------

is there any solution to my problem ??

Yes if you have wired them exactly like this.

You will see on page 2 of the data sheet that you must have a 330R resistor in the supply and a 4u7 capacitor to ground. This is called a decoupling arrangement and it stops the two sensors from interfering with each other. As you said that they work individually but not together, this is why.