Pololu Blog »
Arduino library for Sharp distance sensors
Julien de la Bruère-Terreault (also known as DrGFreeman on the Pololu Forum, creator of the Custom Mini Sumo robot and the Romi and Raspberry Pi robot shared on this blog) made “SharpDistSensor” an Arduino library for analog Sharp distance sensors. If you’re running a recent version of the Arduino IDE, you can install it with the Library Manager. The library reads the sensor’s analog voltage output, filters the data, and converts it to a distance measurement. By default it is calibrated to work with the Sharp GP2Y0A60SZLF analog distance sensor 10-150cm 5V, but you can calibrate it to other analog Sharp distance sensors (if you can fit a power function or a fifth order polynomial to the voltage vs distance response of your sensor). Pull requests are welcome for supporting other Sharp distance sensor models!
The readme, library code, and example sketches are available in the GitHub repository.