IR Detector Emitter BLOWING MY MIND

I have:

https://www.sparkfun.com/products/241

wired in this circuit:

http://www.reconnsworld.com/ir_ultrasonic_basicirdetectemit.html

Running the AnalogInOutSerial example using a Mega. Here is what happens.

Case 1: emitter on detector on aimed directly at each other a few inches away while in sunlight (150ish) Case 2: same as case 1 except I unplug the emitter (1023) Case 3: same as case 1 except no ambient light, meaning I put a box over it (1023)

It seems as if I have some kind of magic detectors that have two be ANDed with the ambient light and emitter light to be turned on. That is, if the ambient light goes away, OR the emitter light goes away, the detector transistor is OFF.

I'm new to this but I hope I explained it where everyone can understand. My mind is officially blown. I tried this with 4 different pairs. Same results.

I would guess a bad ground connection causing the input to go high.

Try going back to Step 1 and putting a block between the emitter and phototransitor instead of unplugging the emitter.

Same result. If I leave the emitter powered up and put an object in the path, it reads 1023.

When the IRED is on (conducting) then the Det out goes Low. When the IRED is off then the Det out goes High.

When the Det is illuminated then its output goes Low. When the Det is not illuminated (in the dark) then its output goes High.

If I leave the emitter powered up and put an object in the path, it reads 1023.

That is the expected result.

Yes. It is. But this only happens when it is exposed to ambient light. When there is ambient light, the pair act as they should. When I put an enclosure over the circuit, meaning no ambient light, the detector reads 1023 no matter what. Please read my original post carefully.

Please read my original post carefully.

You said:-

I'm new to this but I hope I explained it where everyone can understand.

You didn't.

So do you know if the IR emitter is actually emitting? Look at it through the viewfinder of an electronic camera. It could just be you only have half if it working.

I don't have one of those but I would assume that it is working if 1. When I remove the power from the emitter, the detector goes high and 2. If I block the emitter with an object, while powered, the detector goes high Any other case, in ambient light, the detector reads low. I can only assume that it is working or else these actions would have no effect. I've already stated most of this in my original post.

durkinnj: Any other case, in ambient light, the detector reads low. I can only assume that it is working or else these actions would have no effect. I've already stated most of this in my original post.

In ambient light, in most cases it will read low, the phototransistor will be "on"/conducting - they're "infrared" but they're sensitive to visible light, too.