homemade ir sensor trouble

i made a ir sensor from below
http://www.pages.drexel.edu/~pyc23/ir_sensor.html

i have done everything as said in that website and used this code to test the sensor

#define SENSOR 0 // select the input pin for the
// sensor resistor
int val = 0; // variable to store the value coming
// from the sensor
void setup() {
Serial.begin(9600); // open the serial port to send
// data back to the computer at
// 9600 bits per second
}
void loop() {
val = analogRead(SENSOR); // read the value from
// the sensor
Serial.println(val); // print the value to
// the serial port
delay(100); // wait 100ms between
// each send
}

i always get value 1023 or 1022 something within four digits variance can any body help me out please :slight_smile:

First thing is to check that the IR emitter is actually sending something out. You can't see IR but your digital camera can. Look at the emitter in the view finder to see if it is lit.
Then move the emitter very close to the sensor and see if the output changes. Make sure the photo transistor is the right way round. If you are not sure you can swap it over without any risk of damage.
This sort of circuit is not very sensitive and you will have to get closer than a cm to get any reading. Also see if there are any changes when you cup your hands over the sensor to shield it from external light.

all the wiring is ok i dont know what is the problem i need only a 5 cm range can that range be acheivable on this type of sensor? :-?

or can i use a led and ldr to acheive the range of 5 cm ? :-/

It depends a little bit on the parts..
What LED is it: A real IR one? They are black..
I doubt this as 270 Ohms is a little bit high for those current hungry beasts...
But a bright red one will also do..

What fototransitor is it? What is written on it? Does it have three legs??

Also note: This is meant to be a reflective device. The LED does not directly light the transistor. Just try - if not yet glued permantly - to let them look face to face....

You could try and change R2 from 10K to 100 or 200K this will give more of a voltage swing for a given amount of light.
Have you checked that the emitter is shining?

all the wiring is ok

If I had a dollar for every time some one has said that to me and later found out it was not indeed the case I would be a very rich man.

yes the led is a real ir one iam not using a phototransistor but a led to receive also and the ir led is not black though the other one is i donno the transparent led is showing light in a mobile phone camera

hehehe :slight_smile: one dollar hmm might be u'd reallt get rich but i would not let you have that dollar :wink:

yes the led is a real ir one

Are you positive? Have you checked it for operation using a digital camera as Grumpy_Mike suggested?

iam not using a phototransistor but a led to receive also

For the circuit given to work, you must use a phototransistor as a detector; using an LED as a detector is possible, but it requires strong reverse biasing, and even then its not a great detector (its really a hack). Use a proper phototransistor.

Ideally, you purchase your IR LED and phototransistor as a "matched pair"; if you can't, then you need to look at the spec sheets for the parts you are buying, and make sure that the parts will match properly (that is, the output wavelength peak of the IR LED falls within the detection bandwidth of the phototransistor).

and the ir led is not black though the other one is i donno the transparent led is showing light in a mobile phone camera

Ok - so you're saying that the transparent case LED is showing light on the mobile phone camera, but you don't see any visible light emanating from it, correct? I do know that there are transparent case IR LEDs, but most tend to have dark cases (IR transparent, though - they look almost black, sometimes a very deep purple color).

The other LED though - what is it? Is it an IR LED in such a dark case, or is it some other LED? What happens when you use it as the output LED? Do you see visible light or not? What do you see on the camera? If you don't see anything, but the camera picks up something, then it is an IR LED, too - based on your descriptions, anyhow...

Are you sure it isn't a phototransistor (I imagine one could come in such a case, though you usually see other kinds of cases); where did you get these parts, anyhow? There's a lot of unknowns here; maybe you could post some pics of what you are trying to do...

:-?

iam not using a phototransistor but a led to receive

So much for the quote:-

i have done everything as said in that website

Using an LED to act as a photo sensor requites a totally different technique to read it than the software you have.
You have to wire it reverse biased, discharge it, charge it, delay, read the residual charge, it is not a simple matter of just reading the value.
so you can't say:-

all the wiring is ok

because you can not be wiring it up like the diagram shows because you don't have a photo transistor to wire up.
Anyway you will not get the range you want using this technique.
You need a real photo transistor.

__@crosh and grumpy mike__oh, im sorry i bought a paired ir receiver and led i called the receiver a led coz it looked like one ive seen many other cases where a phototransistor had three legs so i called it a led !
i hope its clear now so as what iam using and doing
my emmiter led is transparent and receiver is black in colour :slight_smile:

So now what happens when you put the emitter right up to the detector. Don't think about reflection yet put the two facing each other.
Do you see any change in output?
If not swap over the legs of your detector.
If you still see no change in the numbers you print out there are two possibilities:-

  1. You have wired it up wrong. Try and post a picture of your setup.
  2. You have a faulty photo transistor.

i tried faccccing them but i didnt observe any change
here is the link to the photos
http://picasaweb.google.com/105832557468727161814/IrSensor?authkey=Gv1sRgCOKg3Mbdt-_C6AE#
they might not be that clear but any way have a look at them

now i tried using a green led instesd of the ir led and things seem to be working i get a value ranging from 980 to 1022 and a effextive range of 25 cm what do you people think i even again tried udsing ir pair but i have a problem with them !! any ideas what is the problem with them ? :-?

Facing each other means the round end pointing at the round end. As Richard said you have them facing away from each other in the photo you sent.

If you have them facing each other and if you can see it light up in a camera viewfinder then it will work. You have proved the receiver works by using the green LED. You will get better signals with the IR LED.

well i dont know what is wrong but it is not working with the ir led and its lighting in a mobile phones camera :-/

and the two devices have there domed ends facing each other?

ya what soever may be theiur position there is no differencfe they show the same readings! :frowning:

Sorry I have run out of ideas. I am sure you are doing something wrong but at this distance I can't tell what. If you have it working with a green LED then I would go with that.