0% found this document useful (0 votes)
255 views1 page

Sharp GP2Y0A21YK Distance Sensor Guide

This document provides instructions on using an infrared distance sensor module (Sharp GP2Y0A21YK). It includes the components needed, a circuit diagram, sample Arduino code, and equations to convert the sensor's voltage output or analog readings into distance measurements in centimeters. The sensor returns a voltage between 0.4-3V depending on the distance of an object between 10-80cm, and the equations can calculate distance from this voltage or a 10-bit ADC reading with about 5% accuracy.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
255 views1 page

Sharp GP2Y0A21YK Distance Sensor Guide

This document provides instructions on using an infrared distance sensor module (Sharp GP2Y0A21YK). It includes the components needed, a circuit diagram, sample Arduino code, and equations to convert the sensor's voltage output or analog readings into distance measurements in centimeters. The sensor returns a voltage between 0.4-3V depending on the distance of an object between 10-80cm, and the equations can calculate distance from this voltage or a 10-bit ADC reading with about 5% accuracy.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Sensing Distance (SHARP GP2Y0A21YK)

The Pieces
IR Distance Sensor
(Sharp GP2Y0A21Y)

The Theory & Code


Infra Red Distance Sensor An analog IR distance sensor is a really neat component. Simply connect +5v and ground and a voltage proportional to the distance between the sensor and an object in front of it will be returned (ranging from 0.4 volts at 80 cm to 3 volts at 10 cm). It really couldn't be simpler to use. Converting to Distance The voltage returned is not linear (see graph), however it can be converted to a distance using some simple maths. There will be some variation between models but here are a couple of equations that worked for us (results +-~5%)

x1
Cable
(JST 3 pole)

x1

The Schematic
+5 volts analog pin
source: GP2Y0A21YK Datasheet

signal

gnd +5v

Equations From 10 bit A/D Reading to centimeters (5v supply) distance = 12343.85 * (10bit reading)^-1.15 From Voltage Reading to Centimeters distance = 27.86 (voltage reading)^-1.15 Arduino Code (5v) float distance = 12343.85 * pow(analogRead(sensorPin),-1.15)

gnd (ground) (-)

Technical Details .: Full Datasheet: [Link] :.

The Circuit

The Layout Sheet


A B C D E 1 2 3 4 5 F G H I J 1 2 3 4 5

signal

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

+5v

gnd

6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

to pin 21 analog 0
22 23 24 25 26 27 28 29 30 A B C D E F G H I J

CIRC-20 27
(Sharp29 GP2Y0A21YK)
30

to 5v to Gnd

Distance 28

.: Instructions: print out, cut out, get making :. .: for more details visit: [Link] :.

You might also like