Infrared Distance Measuring Proximity Sensor 20 - 150cm - SHARP GP2Y0A02
- Was RM58.00
-
RM48.00
- Product Code: GP2Y0A02
- Availability: In Stock
The Sharp distance sensor's are a popular choice for many projects that require accurate distance measurements. This IR sensor is more economical than sonar range-finders, yet it provides much better performance than other IR alternatives. Interfacing to most microcontrollers is straightforward: the single analog output can be connected to an analog-to-digital converter for taking distance measurements, or the output can be connected to a comparator for threshold detection. The detection range of this version is approximately 20 cm to 150 cm (8" to 60"). For over 1 m distance, we suggest using sonar sensors.
Features:
Specifications:
// connect gp2d120x to A0 #define pin A0 void setup(){ Serial.begin (9600); pinMode(pin, INPUT); } void loop(){ uint16_t value = analogRead (pin); double distance = get_IR (value); //Convert the analog voltage to the distance Serial.println (value); //Print the data to the arduino serial monitor Serial.print (distance); Serial.println (" cm"); Serial.println (); delay (500); //Delay 0.5s } //return distance (cm) double get_IR(uint16_t value){ if (value < 16) value = 16; return 9462.0 / (value - 16.92); }
View the result in serial monitor.
Tags: IR Infrared, Distance Measuring