Sharp gp2d120 tutorial anywhere???

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  Serial.println(analogRead(0));
  delay(1000);
}

This right here you can measure the distance and write down what the number is for each distance.

int LED =13;

void setup()
{
  pinMode(LED, OUTPUT);
}

void loop()

{
   int distance = analogRead(0);
   
   if ( distance == 321 )
   {
      digitalWrite(LED,HIGH); 
   } 
   else
   {
     digitalWrite(LED,LOW); 
   } 
}

Here is just something to turn and Led on when it equal to the distance I got from the serial print which is 3 inch, yours might be a tad bit different number. Sorry took so long to get back. Let me know if you have any othe question and I will try to help you out.