Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Obstacle Avoiding + IR GP2D12 sensor

Status
Not open for further replies.
Hi All,
i am using the GP2D12 with arduino for obstacle avoiding robot. It was working fine. After some time it stopped working. I tested with the below code

Code:
/*
 read_gp2d12_range
 Function that reads a value from GP2D12 infrared distance sensor and returns a value in centimeters.

 This sensor should be used with a refresh rate of 36ms or greater.

 Javier Valencia 2008

 float read_gp2d12_range(byte pin)

 It can return -1 if something gone wrong.

 */

float read_gp2d12_range(byte pin) {
    int tmp;

    tmp = analogRead(pin);
    if (tmp < 3)
        return -1; // invalid value

    return (6787.0 /((float)tmp - 3.0)) - 4.0;
}

I am getting only 5 to 10cm value. i am not getting more than that. Is my sensor damaged.

Is there any test method for the GP2D12 sensor.

Please help me

Thanks,
Robotsmani
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top