Makeshift IR Proximity / Range Sensor Help

Hello!
I have built an makeshift IR Proximity Sensor. I have written an article (incomplete as of now) about this sensor: http://arduino720.wikispaces.com/Infrared (last article). This makeshift sensor consists of a 880 nm IR Emitter placed right beside a IR Phototransistor. Both components are facing forward. The emitter sends out a ray of IR light, and the phototransistor picks up the ray of light when it bounces off objects in front of it. The phototransistor is covered with a piece of grabge bag plastic to filter visible light, minimizing interference from visible light sources inside the house. In a room lit with energy-saving bulbs at night, the sensor has a range of about 5 cm. However, the IR Phototransistor receives a considerable amount of interference when exposed to sunlight. I know that there are IR Range Finders (e.g. Sharp GP2D120) on the market with high resolution and range, with very little interference and function similarly. How can I change my makeshift sensor to cut out interference from sunlight?
Thanks!

Hi,

I might not understand your proximity sensor.

What most IR protocols do is send a train of pulses on a carrier frequency, and decode this train of pulses to see if it is a relevant signal. It is important that it is a train of ON OFF pulses. Most sensors have a built in threshold which adjusts when a constant amount of IR led falls on the sensor. As far as I can tell you have the IR led directly connected to Vcc, so it is always ON. I suggest using a PWM pin on a frequency which corresponds to your sensor (36 - 40 kHz most likely). I used this combination to detect a drop of water falling towards a puddle of water and make a camera take a picture. Ken Sheriffs library should get you going. However, you pointed most of these things out on your page, so I might not understand the question.

Regarding sunlight: I have built lasertaggers sending IR packets to each other, range is diminished when sun is shining. I have a different set of resistors for inside and outside play, so you might well need an extra light sensor to see "how bright the sun is" and adjust the resistor used for your IR led based on those readings.

Cheers, Jack

My first idea was to get an identical IR phototransistor (ambient sensor), place it facing up on the breadboard to measure the ambient IR light and "subtract" it from the other IR phototransistor (proximity sensor), but I can't get my hands on any new components anytime soon. So I posted this to see if people will suggest other methods.

[note to self: check login status before typing reply]

If your sensor returns a voltage depending on the amount of IR light received, disregard my previous statements about PWM-usage. You do not need the IR library at all. The sensors used in the library are all binary active sensors, active in the sense they do some filtering for you. They only return HIGH (for gap) or LOW (for mark).

You might have a spare led lying around, I suppose IR would be best, because you can construct a very crude light sensor from a led:

http://playground.arduino.cc/Learning/LEDSensor