Need BAP sample code for GP2Y0D805Z0F digital IR sensor

I’ve been looking to get this pololu.com/catalog/product/1134 sensor lately but I haven’t seen any Basic Atom Pro sample code on it. So I was just wondering if anyone out their has used this with a BAP. I’d also like an opinion on how well it works compared to Sharp’s analog sensors.

Have not used them. But interfacing to them should be very easy. Simply connect up to BAP pin, set that pin to input and then read the input value for that pin. My quick look at the specification says that the voltage level will be low when it detects something… So if you wish for example to detect an object and the sensor is connect to pin 0 you could probably do something like:

;Wait for sensor to detect object
input p0
while in0
   ; could be doing something while waiting...
wend
; object was detected...

How does it compare to analog sensors? Depends. If you only wish to know the object is seen in the predefined range of the sensor (2-5 cm?) than this works great. Also is nice that you can use any IO pin, instead of being limited to the 8 analog pins of the Bap28.

If however you wish to know additional information like where the object is within the range of the sensor, than the analog ones may work better for you. Example if you have two sensors and you wish to know which one of the sensors is closer to the object… Also with the board you mentioned, by default the sensor is always sending/enabled, so not sure how well it works with multiple of them. You can cut the enable connection and run an additional wire to control it, but that takes an additional IO pin…

So it is a trade off of which will work better for you.

Kurt

Thanks for the professional opinion. I’ll be getting a few of them sometime next week. Also, since I haven’t seen any lynxmotion forum posts on Sharp’s digital sensors, I’ll post on how I get along with them.

Ok, I’ve been working with this sensor for a while and it works quite well for very close range object detection. Here is my sample code.

main input p0 if in0 then serout s_out,i9600,"Nothing Here",13] pause 250 else serout s_out,i9600,"Object Detected",13] pause 250 endif goto main

So that this post shows up on someone’s search for this particular sensor if someone is looking for it allow me to post the following key words.

GP2Y0D810Z0F
GP2Y0D805Z0F
digital
IR
sharp

I hope this helps someone because I know how it feels to not be able to quickly find sample code for a sensor and be to noobish to effectively create your own. :slight_smile: