{"product_id":"136-sharp-gp2y0a21yk0f-analog-distance-sensor-10-80cm","title":"Sharp GP2Y0A21YK0F Analog Distance Sensor 10-80cm","description":"\u003cp\u003eThe GP2Y0A21 Sharp distance sensor is a great way to add obstacle avoidance or motion sensing to your robot or any other project. With a detection range of 4″ to 32″ (10 cm to 80 cm) and an analog voltage indicating the distance, this sensor is very easy to use.\u003c\/p\u003e\n\u003cbr\u003e\u003ctable class=\"picture_with_caption right\"\u003e\u003ctr\u003e\n\u003ctd\u003e\u003ca href=\"https:\/\/a.pololu-files.com\/picture\/0J1466.1200.jpg?7b043b12c9f2f938a294daf56169ef35\" class=\"noscript-fallback\"\u003e\u003cimg alt=\"\" class=\"zoomable\" data-gallery-pictures=\"[{\" id jst ph-style cable connected to a sharp analog distance sensor. data-picture-id=\"0J1466\" data-picture-longest_side=\"800\" src=\"https:\/\/a.pololu-files.com\/picture\/0J1466.200.jpg?7b043b12c9f2f938a294daf56169ef35\"\u003e\u003c\/a\u003e\u003c\/td\u003e\n\u003cp\u003e\u003c\/p\u003e\n\u003c\/tr\u003e\u003c\/table\u003e\n\u003ch2\u003eOverview\u003c\/h2\u003e\n\u003cp\u003eThe Sharp distance sensors are a popular choice for many projects that require accurate distance measurements.  This IR sensor is more economical than sonar rangefinders, 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″).\u003c\/p\u003e\n\u003cp\u003eThe GP2Y0A21 uses a 3-pin JST PH connector that works with our 3-pin JST PH cables for Sharp distance sensors (not included), as shown in the upper picture on the right.  These cables have 3-pin JST connectors on one end and are available with \u003ca href=\"https:\/\/www.pololu.com\/product\/1799\"\u003epre-crimped male pins\u003c\/a\u003e, \u003ca href=\"https:\/\/www.pololu.com\/product\/1798\"\u003epre-crimped female pins\u003c\/a\u003e, and with \u003ca href=\"https:\/\/www.pololu.com\/product\/117\"\u003eunterminated wires\u003c\/a\u003e on the other end.  It is also possible to solder three wires to the sensor where the connector pins are mounted (see the lower picture to the right).  When looking at the back, the three connections from left to right are power, ground, and the output signal.\u003c\/p\u003e\n\u003cp\u003eWe also carry an assortment of \u003ca href=\"https:\/\/www.pololu.com\/category\/160\/brackets-for-sharp-distance-sensors\"\u003emounting brackets\u003c\/a\u003e designed specifically for this sensor:\u003c\/p\u003e\n\u003ctable class=\"side_by_side_pics\"\u003e\n\t\u003ctr\u003e\n\t\t\u003ctd\u003e\u003ctable class=\"picture_with_caption center\"\u003e\u003ctr\u003e\u003ctd\u003e\u003ca href=\"https:\/\/a.pololu-files.com\/picture\/0J5937.1200.jpg?b53665bf37bd813287d92358730643e1\" class=\"noscript-fallback\"\u003e\u003cimg alt=\"\" class=\"zoomable\" data-gallery-pictures=\"[{\" id gp2y0a21 distance sensor mounted using a bracket for sharp gp2y0a02 and gp2y0a41 sensors parallel. data-picture-id=\"0J5937\" data-picture-longest_side=\"1200\" src=\"https:\/\/a.pololu-files.com\/picture\/0J5937.175.jpg?b53665bf37bd813287d92358730643e1\"\u003e\u003c\/a\u003e\u003c\/td\u003e\u003c\/tr\u003e\u003c\/table\u003e\u003c\/td\u003e\n\t\t\u003ctd\u003e\u003ctable class=\"picture_with_caption center\"\u003e\u003ctr\u003e\u003ctd\u003e\u003ca href=\"https:\/\/a.pololu-files.com\/picture\/0J5945.1200.jpg?9917ffbce8d51122799c47860fe90cc5\" class=\"noscript-fallback\"\u003e\u003cimg alt=\"\" class=\"zoomable\" data-gallery-pictures=\"[{\" id mounting of a sharp distance sensor using modified bracket for gp2y0a02 gp2y0a21 and gp2y0a41 sensors multi-option. data-picture-id=\"0J5945\" data-picture-longest_side=\"1200\" src=\"https:\/\/a.pololu-files.com\/picture\/0J5945.175.jpg?9917ffbce8d51122799c47860fe90cc5\"\u003e\u003c\/a\u003e\u003c\/td\u003e\u003c\/tr\u003e\u003c\/table\u003e\u003c\/td\u003e\n\t\t\u003ctd\u003e\u003ctable class=\"picture_with_caption center\"\u003e\u003ctr\u003e\u003ctd\u003e\u003ca href=\"https:\/\/a.pololu-files.com\/picture\/0J5934.1200.jpg?b9c34fc54a7a08666b4a35f5b4c8396b\" class=\"noscript-fallback\"\u003e\u003cimg alt=\"\" class=\"zoomable\" data-gallery-pictures=\"[{\" id gp2y0a21 distance sensor mounted using a bracket for sharp gp2y0a02 and gp2y0a41 sensors perpendicular. data-picture-id=\"0J5934\" data-picture-longest_side=\"1200\" src=\"https:\/\/a.pololu-files.com\/picture\/0J5934.175.jpg?b9c34fc54a7a08666b4a35f5b4c8396b\"\u003e\u003c\/a\u003e\u003c\/td\u003e\u003c\/tr\u003e\u003c\/table\u003e\u003c\/td\u003e\n\t\u003c\/tr\u003e\n\u003c\/table\u003e\n\u003ctable class=\"picture_with_caption center\"\u003e\n\u003ctr\u003e\u003ctd style=\"max-width: 450px\"\u003e\u003ca href=\"https:\/\/a.pololu-files.com\/picture\/0J5938.1200.jpg?6c7383637a56aea25e008b42dc2cc1b4\" class=\"noscript-fallback\"\u003e\u003cimg alt=\"\" class=\"zoomable\" data-gallery-pictures=\"[{\" id of brackets for sharp gp2y0a02 gp2y0a21 and gp2y0a41 distance sensors. data-picture-id=\"0J5938\" data-picture-longest_side=\"1200\" src=\"https:\/\/a.pololu-files.com\/picture\/0J5938.450.jpg?6c7383637a56aea25e008b42dc2cc1b4\"\u003e\u003c\/a\u003e\u003c\/td\u003e\u003c\/tr\u003e\n\u003ctr\u003e\u003cth style=\"max-width: 450px\"\u003e\u003cp\u003eFamily of brackets for Sharp GP2Y0A02, GP2Y0A21, and GP2Y0A41 Distance Sensors.\u003c\/p\u003e\u003c\/th\u003e\u003c\/tr\u003e\n\u003c\/table\u003e\u003ctable class=\"picture_with_caption right\"\u003e\u003ctr\u003e\n\u003ctd\u003e\u003ca href=\"https:\/\/a.pololu-files.com\/picture\/0J147.1200.jpg?a7fb010056cf8b8f32195e9d8fdeb4a4\" class=\"noscript-fallback\"\u003e\u003cimg alt=\"\" class=\"zoomable\" data-gallery-pictures=\"[{\" id analog distance sensor back view with wires soldered directly to the pcb. data-picture-id=\"0J147\" data-picture-longest_side=\"240\" src=\"https:\/\/a.pololu-files.com\/picture\/0J147.200.jpg?a7fb010056cf8b8f32195e9d8fdeb4a4\"\u003e\u003c\/a\u003e\u003c\/td\u003e\n\u003cp\u003e\u003c\/p\u003e\n\u003c\/tr\u003e\u003c\/table\u003e\n\u003ch2\u003eFeature summary\u003c\/h2\u003e\n\u003cul\u003e\n\t\u003cli\u003eOperating voltage: 4.5 V to 5.5 V\u003c\/li\u003e\n\t\u003cli\u003eAverage current consumption: 30 mA (\u003cstrong\u003enote:\u003c\/strong\u003e this sensor draws current in large, short bursts, and the manufacturer recommends putting a 10 µF capacitor or larger across power and ground close to the sensor to stabilize the power supply line)\u003c\/li\u003e\n\t\u003cli\u003eDistance measuring range: 10 cm to 80 cm (4″ to 32″)\u003c\/li\u003e\n\t\u003cli\u003eOutput type: analog voltage\u003c\/li\u003e\n\t\u003cli\u003eOutput voltage differential over distance range: 1.9 V (typical)\u003c\/li\u003e\n\t\u003cli\u003eUpdate period: 38 ± 10 ms\u003c\/li\u003e\n\t\u003cli\u003eSize: 44.5 mm × 18.9 mm × 13.5 mm (1.75″ × 0.75″ × 0.53″)\u003c\/li\u003e\n\t\u003cli\u003eWeight: 3.5 g (0.12 oz)\u003c\/li\u003e\n\u003c\/ul\u003e\n\u003ctable class=\"picture_with_caption right\"\u003e\u003ctr\u003e\n\u003ctd\u003e\u003cimg alt=\"\" class=\"\" data-gallery-pictures=\"[{\" id gp2y0a21yk distance sensor distance-to-voltage graph. data-picture-id=\"0J387\" data-picture-longest_side=\"300\" src=\"https:\/\/a.pololu-files.com\/picture\/0J387.300.gif?b9f68c19a51ecc945a3d461cc114d83e\"\u003e\u003c\/td\u003e\n\u003cp\u003e\u003c\/p\u003e\n\u003c\/tr\u003e\u003c\/table\u003e\n\u003ch2\u003eLinearizing the output\u003c\/h2\u003e\n\u003cp\u003eThe relationship between the sensor’s output voltage and the inverse of the measured distance is approximately linear over the sensor’s usable range.  The \u003ca href=\"\/file\/0J85\/gp2y0a21yk0f.pdf\"\u003eGP2Y0A21YK datasheet\u003c\/a\u003e (374k pdf) contains a plot of analog output voltage as a function of the inverse of distance to a reflective object.  You can use this plot to convert the sensor output voltage to an approximate distance by constructing a best-fit line that relates the inverse of the output voltage (V) to distance (cm).  In its simplest form, the linearizing equation can be that the distance to the reflective object is approximately equal to a constant scale factor (~27 V*cm) divided by the sensor’s output voltage.  Adding a constant distance offset and modifying the scale factor can improve the fit of this line.\u003c\/p\u003e\n\u003ch2\u003eAlternative Sharp distance sensors\u003c\/h2\u003e\n\u003cp\u003eWe have a variety of Sharp distance sensors to choose from, including the \u003ca href=\"https:\/\/www.pololu.com\/product\/2464\"\u003eshorter-range (4 – 30 cm) GP2Y0A41SK0F\u003c\/a\u003e and \u003ca href=\"https:\/\/www.pololu.com\/product\/1137\"\u003elonger-range (20 – 150 cm) GP2Y0A02YK0F\u003c\/a\u003e.  These analog distance sensors have similar packages and identical pin-outs, making it easy to swap one version for another should your application requirements change.  We also carry the newer \u003ca href=\"https:\/\/www.pololu.com\/product\/2474\"\u003eSharp GP2Y0A60SZ analog distance sensor\u003c\/a\u003e (10 – 150 cm), which outperforms the other analog Sharp distance sensors in almost all respects, offering a low minimum detection distance, high maximum detection distance, wide 3 V output voltage differential, high 60 Hz sampling rate, operation down to 2.7 V, and optional enable control, all in a smaller package.\u003c\/p\u003e\n\u003ctable class=\"picture_with_caption center\"\u003e\n\u003ctr\u003e\n\u003ctd style=\"max-width: 470px\"\u003e\u003ca href=\"https:\/\/a.pololu-files.com\/picture\/0J5788.1200.jpg?e76bc7fce22d2bbb4667acc943debf0e\" class=\"noscript-fallback\"\u003e\u003cimg alt=\"\" class=\"zoomable\" data-gallery-pictures=\"[{\" id gp2y0a02yk0f sensor next to pololu carrier with sharp gp2y0a60szlf data-picture-id=\"0J5788\" data-picture-longest_side=\"1200\" src=\"https:\/\/a.pololu-files.com\/picture\/0J5788.470.jpg?e76bc7fce22d2bbb4667acc943debf0e\"\u003e\u003c\/a\u003e\u003c\/td\u003e\n\u003cp\u003e\u003c\/p\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\u003cth style=\"max-width: 470px\"\u003e\u003cp\u003eSharp GP2Y0A02YK0F Sensor 20-150cm (left) next to Pololu Carrier with Sharp GP2Y0A60SZLF Sensor 10-150cm (right).\u003c\/p\u003e\u003c\/th\u003e\u003c\/tr\u003e\n\u003c\/table\u003e\n\u003cp\u003eFor very short-range detection applications, we carry a \u003ca href=\"https:\/\/www.pololu.com\/product\/2450\"\u003e2-15 cm analog Sharp distance sensor\u003c\/a\u003e.  We also carry three digital Sharp distance sensors that have low minimum detection distances and a high 400 Hz update rate.  They are available with a \u003ca href=\"https:\/\/www.pololu.com\/product\/1132\"\u003e5 cm\u003c\/a\u003e, \u003ca href=\"https:\/\/www.pololu.com\/product\/1134\"\u003e10 cm\u003c\/a\u003e, or \u003ca href=\"https:\/\/www.pololu.com\/product\/2465\"\u003e15 cm\u003c\/a\u003e range and simply tell you if something is in their detection range, not how far away it is.  They are smaller than the analog Sharp distance sensors and draw less current.\u003c\/p\u003e\n\u003ctable class=\"picture_with_caption center wide\"\u003e\n\u003ctr\u003e\n\u003ctd style=\"max-width: 600px\"\u003e\u003ca href=\"https:\/\/a.pololu-files.com\/picture\/0J6051.1200.jpg?4567baeed058eeddf63955f8fdf44bde\" class=\"noscript-fallback\"\u003e\u003cimg alt=\"\" class=\"wide zoomable\" data-gallery-pictures=\"[{\" id variety of sharp distance sensors. from left to right: gp2y0a02 gp2y0a21 or gp2y0a41 gp2y0a51 and gp2y0d8xx. data-picture-id=\"0J6051\" data-picture-longest_side=\"1200\" src=\"https:\/\/a.pololu-files.com\/picture\/0J6051.600.jpg?4567baeed058eeddf63955f8fdf44bde\"\u003e\u003c\/a\u003e\u003c\/td\u003e\n\u003cp\u003e\u003c\/p\u003e\n\u003c\/tr\u003e\n\u003ctr\u003e\u003cth style=\"max-width: 600px\"\u003e\u003cp\u003eA variety of Sharp distance sensors.  From left to right: GP2Y0A02, GP2Y0A21 or GP2Y0A41, GP2Y0A51, and GP2Y0D8xx.\u003c\/p\u003e\u003c\/th\u003e\u003c\/tr\u003e\n\u003c\/table\u003e\n\u003cp class=\"note clear\"\u003e\u003cstrong\u003eNote:\u003c\/strong\u003e  The GP2Y0A21YK0F model is a lead-free, RoHS-compliant version of the Sharp GP2Y0A21 Distance Sensor.  The manufacturer recommends you insert a bypass capacitor of 10 µF or more between Vcc and GND near this sensor to stabilize your power supply line.\u003c\/p\u003e","brand":"Sharp\/Socle","offers":[{"title":"2-4 Settimane","offer_id":47700152680793,"sku":"POL-136","price":18.96,"currency_code":"EUR","in_stock":true},{"title":"1 Giorno","offer_id":47886032765273,"sku":"POL-136\/A","price":18.96,"currency_code":"EUR","in_stock":false}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0781\/1009\/7753\/files\/0J149.1200_aa7bbdc1-65ed-436d-afa3-cc68a7c1b62e.jpg?v=1705513990","url":"https:\/\/xernuqvalzi.pro\/products\/136-sharp-gp2y0a21yk0f-analog-distance-sensor-10-80cm","provider":"Robot Italy","version":"1.0","type":"link"}