Sharp IR sensor

Hi,
I am new with arduino and I would like to set up my controller to use a Sharp GP2D12 IR sensor as a prox sensor. I have used the code for potentiometers that is available on the adruino website, however it blinks the led based on how close you are to the sensor. I would like to program it so that I can set a distance and the LED will turn on if I am within that distance. Can anyone help me with this?

Thanks,
Dan

Here's the approach I would take:

Use the read_gp2d12_range function on this page:

http://www.arduino.cc/playground/Main/ReadGp2d12Range

float desired_distance = 25.0;  // 25 centimeters

float distance_in_cm = read_gp2d12_range (sharpIR_pin);

if (distance_in_cm >= desired_distance) {
    digitalWrite(ledpin, ON);
}
if (distance_in_cm < desired_distance) {
    digitalWrite(ledpin, OFF);
}

That's kind of a rough outline, but should give you something to work with. Just remember you can't (or shouldn't) test for == with a float variable.

-transfinite

Thanks ill give that a try.

-Dan