robotsmani
Member
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
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
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