Go Down

Topic: Struggling to receive the correct data from a IR Sensor. Help please... (Read 1 time) previous topic - next topic

Silent Siren

Hi all, I'm struggling to " read " my Sharp IR GP2Y0D340K Sensor.

Firstly I want to know how to connect the sensor to the arduino. If have looked and followed the diagram of the sensor in the following link : http://sharp-world.com/products/device/lineup/data/pdf/datasheet/gp2y0d340k_e.pdf (note it's a pdf file). I have wired the sensor to the arduino by connecting the pin 1 of the sensor to the 3.3 V on the arduino, pin 2,4 and 5 of the sensor to the ground of the arduino with the neccesary componnets (capacitator and resistor), and pin 3 to the analog input pin of the arduino. Is this correct?

I then used  the simple  AnalogReadSerial aswell as a modified AnalogInOutSerial example in the library of the arduino. Again, is this correct? When I open the serial monitor I only receive a constant value which doesn't change if the sensors orientation changes or the distence changes. I know this a proximity sensor which only gives output values, I think of 1 and 0, but the sensor gives me readings from 0 to 1023, but these values differ on the start of the serial monitor , not through out the  "running" of the code.

Can someone please help me with : connecting the sensor to the arduino correctly if it isn't and help me with reading the sensor correctly so that it only gives a value of 1 or 0.
Any help will be grately appreciated, or even just a link to website that can help me. Tnx all.

AWOL

Quote
have wired the sensor to the arduino by connecting the pin 1 of the sensor to the 3.3 V on the arduino

The datasheet you linked shows operating voltage as 4.5 to 5.5V.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Silent Siren

Tnx AWOL , but if also tried that, I'm am now getting readings of 1023 dropping to about 900 if a object is in front of the sensor, and a value from 0 to about 100 when there is no object. Any idea why its so inconsistnet? I would also like to know how to map these valuese to 0 and 1, is'nt this a proximity sensor which only gives a value of 1 and 0? Tnx very much

AWOL

Quote
I would also like to know how to map these valuese to 0 and 1, is'nt this a proximity sensor which only gives a value of 1 and 0?

Yes, it is a digital device - why bother reading it with an analogRead?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

johnwasser


I have wired the sensor to the arduino by connecting the pin 1 of the sensor to the 3.3 V on the arduino, pin 2,4 and 5 of the sensor to the ground of the arduino with the neccesary componnets (capacitator and resistor), and pin 3 to the analog input pin of the arduino. Is this correct?


You don't mention connecting Pin 6 to ground.

You don't mention providing the recommended bypass capacitor:

Advice for the power supply
• In order to stabilize power supply line, we recommend to insert a by-pass capacitor of 47 ?F or more between Vcc and GND near this product.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Silent Siren

Tnx John and AWOL , if got every working and functioning correctly  :). I only want to know wat is the siggnificence of connecting pin6 to ground and how do I reduce the distance that the sensor can receive? 

AWOL

It looks like pin 6 is just a shield - an extra case ground.
From the datasheet, it looks like the detection distance is fixed.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy