Distance sensor value

If we use distance sensor gp2y0d810z, can measure the distance with it or it just detect whether there is something in front of the sensor ? (e.g. digital values, 0 and 1)
sharp-world.com/products/device/ … 810z_e.pdf

Because I’ve got weird values for the distance and voltage value when I tested using this code:

#include <gp2y0d810z.h>
gp2y0d810z Dist;
int distance;
void setup()
void loop()
  distance = Dist.getDistanceVolt();
  Serial.print("\nADC input mV: ");
  delay(500); //make it readable

As the data sheet clearly shows, this digital device detects whether or not a reflective object is within 100 mm of the optical elements.


As Jim pointed out, the Sharp GP2Y0D810Z0F Digital Distance Sensor can detect if an object is present but not how far away the object is. It does this by outputting a low signal when an object is detected, and a high signal otherwise.

We carry two analog distance sensors, the Sharp GP2Y0A21YK0F and Sharp GP2Y0A02YK0F, that can report the distance to the detected object rather than simply if an object is detected. Please note that the two analog sensors have longer minimum detection distances and slower response times than the digital sensor.