Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

Pololu Carrier with Sharp GP2Y0D805Z0F Digital Distance, how to measure distance

Hello Guys. I have purchased a Pololu Carrier with Sharp GP2Y0D805Z0F Digital Distance Sensor 5cm, but I am unable to find any compatible code to measure the distances. I needed a project where I need to measure small distances.

void setup(){
Serial.begin(9600);
}
void loop() {
Serial.print("Digital Signal:");
Serial.println(digitalRead(3),BIN);
delay(50);
}

Hello.

Unfortunately, I suspect that is not a good sensor for what you are trying to do. The GP2Y0D805Z0F is only good for detecting if an object is detected between 0.5cm and 5cm; it cannot be used to measure distances. If you need to measure distances, you might consider the Sharp GP2Y0A51SK0F which reports distance with an analog voltage.

Alternatively, you might consider one of our Lidar/Time-of-Flight Range Finders or our new Pololu Distance Sensor with Pulse Width Output. The interfaces for reading these sensors are more complicated, but for most of these products we have example code such as Arduino libraries available.

- Patrick