Difference between revisions of "SHARP IR Ranger Sensor GP2D12 for Arduino"
From Geeetech Wiki
(→Usage) |
(→Introduction) |
||
Line 1: | Line 1: | ||
==Introduction== | ==Introduction== | ||
− | [[File:GP2D12 1.jpg]] | + | [[File:GP2D12 1.jpg|250px]] |
The Sharp GP2D12 is an analog distance sensor that uses infrared to detect an object between 10 cm and 80 cm away. The GP2D12 provides a non-linear voltage output in relation to the distance an object is from the sensor and interfaces easily using any analog to digital converter. | The Sharp GP2D12 is an analog distance sensor that uses infrared to detect an object between 10 cm and 80 cm away. The GP2D12 provides a non-linear voltage output in relation to the distance an object is from the sensor and interfaces easily using any analog to digital converter. |
Latest revision as of 02:08, 25 May 2012
Introduction
The Sharp GP2D12 is an analog distance sensor that uses infrared to detect an object between 10 cm and 80 cm away. The GP2D12 provides a non-linear voltage output in relation to the distance an object is from the sensor and interfaces easily using any analog to digital converter.
Specification
- Measuring range : 10 to 80 cm
- The maximum allowable Angle : > 40 °
- The power supply voltage : 4.5 to 5.5 V
- The average power consumption : 35 mA
- Peak power consumption : about 200 mA
- The frequency of updates/cycle : 25 Hz/40 ms
- Analog output noise : < 200 mV
Document
Pinout
Usage
Here is the guide illustrates how to connect an Arduino to the ADXL335 breakout board.
Example code
char GP2D12; char a,b; void setup() { Serial.begin(9600); // } void loop() { int val; GP2D12=read_gp2d12_range(0); a=GP2D12/10; b=GP2D12%10; val=a*10+b; if(val>10&&val<80) { Serial.print(a,DEC);// Serial.print(b,DEC);// Serial.println("cm");// } else Serial.println("over");// delay(50); } float read_gp2d12_range(byte pin) { int tmp; tmp = analogRead(pin); if (tmp < 3)return -1; return (6787.0 /((float)tmp - 3.0)) - 4.0; }
How to buy
Click here to buy SHARP IR Ranger Sensor GP2D12