* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Sensing Distance (SHARP GP2Y0A21YK)
Current source wikipedia , lookup
Ground (electricity) wikipedia , lookup
History of electric power transmission wikipedia , lookup
Buck converter wikipedia , lookup
Signal-flow graph wikipedia , lookup
Rectiverter wikipedia , lookup
Switched-mode power supply wikipedia , lookup
Ground loop (electricity) wikipedia , lookup
Alternating current wikipedia , lookup
Voltage regulator wikipedia , lookup
Surge protector wikipedia , lookup
Resistive opto-isolator wikipedia , lookup
Stray voltage wikipedia , lookup
Voltage optimisation wikipedia , lookup
Sensing Distance (SHARP GP2Y0A21YK) The Pieces The Theory & Code IR Distance Sensor (Sharp GP2Y0A21Y) x1 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%) 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: http://tinyurl.com/yh7chku :. The Layout Sheet A B C D E F G H I J 1 1 2 2 3 3 4 4 8 +5v 5 6 7 gnd 5 6 signal The Circuit 7 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 to pin 21 analog 0 22 22 23 23 24 24 25 26 CIRC-20 27 Distance 28 (Sharp29 GP2Y0A21YK) 25 to 5v 26 27 28 to Gnd 29 30 30 A B C D E .: Instructions: print out, cut out, get making :. .: for more details visit: http://tinyurl.com/y9bjsjp :. F G H I J