Difference between revisions of "SHARP IR Ranger Sensor GP2D12 for Arduino"

From Geeetech Wiki
Jump to: navigation, search
(Created page with "==Introduction== File:GP2D12 1.jpg 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 ...")
 
(Usage)
Line 22: Line 22:
 
Here is the guide illustrates how to connect an Arduino to the ADXL335 breakout board.
 
Here is the guide illustrates how to connect an Arduino to the ADXL335 breakout board.
  
[[File:GP2D12 wiring.jpg|500px]]
+
[[File:GP2D12 wiring.jpg|400px]]
  
 
==Example code==
 
==Example code==

Revision as of 02:07, 25 May 2012

Introduction

GP2D12 1.jpg

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

SHARP GPD2D12 datasheet

Pinout

GP2D12 pin.jpg

Usage

Here is the guide illustrates how to connect an Arduino to the ADXL335 breakout board.

GP2D12 wiring.jpg

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