Sharp GP2Y0A021YK infrared sensor = sharp gp2d12?

HI! I really need your help on this one...

I know that sharp gp2d12 and sharp GP2Y0A21YK0F is different in means of detection area, but my question is however i can use this library from arduino playground: (see link in next post)

you are of so great help if you help me with this project that has a tight deadline


link to arduino playground:

Without taking a close look at the sensors you mention I would answer your question with a "yes, but".

The sketch simply reads a value from the ADC then applies a formula to that value in order to determine the distance.

There is no reason you can't use that method, BUT, the formula is likely to be different for the two sensors.

You should compare the datasheets for the two sensors to see what differences there are. IIRC they have graphs indicating the relationship between distance and output voltage. It is this relationship that the formula is trying to express.



I´ll do that. As long as I get analog variables from the sensor that could be interpreted in arduino I think I´ll make it.... thank you!