I’m trying to use a Sharp GP2Y0D805Z0F Digital Distance Sensor, with the carrier board. Without any success. Using the simple analogRead example just to test the sensor, I get a constant reading of 50 with occasional drift to 49 or 51. Regardless of object distance.
I have Vcc connected to +5v and gnd to gnd as well. Output going to A0, so everything is hooked up correctly. I tried adding capacitors of varying capacity with no effect. Any help would be appreciated.
You should be able to test if the sensor is working without even using the Arduino (I’m assuming that’s what you’re using?). With just power connected, what behavior do you see from the red LED on the back of the board as you pass an object back and forth in front of the sensor?
The LED is connected directly to the sensor output pin, so it sounds like the sensor should be working for you now. You can read the sensor using an analog input if you really want to, but there isn’t any point since it’s a digital output. You can just connect it to a digital input and perform a digital read (which is much faster than an analog read, and you’re not wasting a valuable analog input).
It seems to work now but the value doesn’t change much with distance. In fact from 2cm to 5cm it reads the same(give or take 1 or 2) then after 5cm nothing.perhaps I got the wrong sensor?
I don’t know about any tutorials, but the product web page has quite a bit of information. Have you read that? From the product page:
The “digital” in Digital Distance sensor means that you only get a high/low response, with low meaning “I see something” and high meaning “I don’t see something”. If you want to know how far away something is, you need a different sensor, such as a Sharp analog distance sensor or a sonar rangefinder. However, these rangefinders typically have minimum detection distances that are much longer than the 5mm minimum sensing distance of the sensor you have now.
Ok I feel like an idiot It makes sense now. For some reason I thought I could measure distance. I just need a different sensor. Thanks for your time and patience.
Don’t feel too bad. At least the sensor you got is fairly inexpensive, and maybe you can find a use for it in a future project. If you want any help selecting a replacement sensor, you can tell us more about what you’re trying to do.
Well I think I’ll find a use for it eventually! I’m building a robot and I need some sort of obstacle avoidance. I want it to be semi autonomous , not just bump n go…
I think the easiest things to use would be Sharp analog distance sensors. There are three different versions available, each with a different sensing range. You might want to use more than one so that you can better detect obstacles around you.