Arduino-GP2Y0A21YK-library
Arduino-GP2Y0A21YK-library copied to clipboard
Wrong distance values
I used this Library with an GP2Y0A21YK Sensor and run the Example code for reading Centimeter on an Arduino Nano und am receiving incorrect values. I meassured the distance with a tape meter and at 15cm I get the Serial reading "8", at 20cm I get "11", at 25cm I get "13", at 30cm I get "15". What could cause those misreadings?
Could you check the analog value on the ADC input at these distances? Check the datasheet to see what distance corresponds to your measured value to see where the problem is located. (Arduino/code or the sensor)
The distance is indeed not correct. I have two of these sensors at the moment. And I have compared them both with the data sheet of this sensor. At around 1.3V it should be 20cm, but your code gives 10cm. And it is still significant of at other ranges also.
After using your combined library of distance sensors, the distance is correct.