Ir object detector

good morning

as always excuse my awful english

i made an ir object detector but the problem is that as long as the led is connected to the pwm and there is a pulse my microcontroller detects signal! thats weird even i covered the ir led with my hand and it still recives the signal only stop reciving the signal if the pwm stopped or if the led is removed

how can that happen and how to solve this problem? i am doing the circuit in here http://pic-tronics.com/IR-Object-Detector.php

help please

Did you remember to set the

Did you remember to set the detector pin as an “INPUT”? Sounds like maybe the pin is floating.

EDIT: Hmmm, Nevermind, I checked your link and saw it was for PIC.

I second Yahmez’ question.

Does your IR receiver look exactly like the one that is being used in the video? I have seen many of those receivers without the metal shield. If yours doesn’t have the sheild, IR leakage could be the problem. There are a a few easy fixes at that point. Heatshrink tube around the IR LED is an easy option. Also, realize the circuit you are building will sense up to a given distance. Put another way, without changing the code, you won’t be able to sense distance to an object only the presence or lack thereof of an object.

it has the shield arund it

it has the shield arund it already and i tried heatshrinking for the led and it still gets the signal to the reciver

:slight_smile:

:slight_smile:

do u know a spefic way to

do u know a spefic way to mesure the distance of the reciver ? or how to calculate it?

I will attempt to describe what you are attempting to copy.

The IR receiver outputs a HIGH signal whenever it senses an approximate 38khz (or 36khz or 40khz depending on the model) signal. You will never get anything but a HIGH or a LOW. The max range is probably maybe 120mm(?). Your range will be dependent on LED brightness, and, environment. The only way to get any kind of distance approximation out of this circuit would be to vary the LED brightness.

You would be better off with IR LEDs and IR Phototransistors. You would then need enough analog pins to connect to. After that it is a simple matter of comparing the ADC numbers to get an idea about how far away an object is. You won’t be winning any accuracy contests, but, otherwise it should work well enough.