Infrared Distance Measuring Proximity Sensor 10 - 80cm - SHARP GP2Y0A21YK0F
- Was RM40.00
-
RM32.00
- Product Code: GP2Y0A21YK0F
- 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 10 cm to 80 cm (4" to 32").
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 4800.0 / (value - 1120.0); }
View the result in serial monitor.
Tags: IR Infrared, Distance Measuring