_SKU_SEN0013_Sharp_GP2Y0A02YK_红外测距传感器__20~150cm_ - jimaobian/DFRobotWikiCn GitHub Wiki
简介
GP2Y0A02YK是夏普红外距离传感器家族成员之一,此型号可提供高达150cm的探测距离,同样也拥有夏普在红外距离探测领域一贯的品质。
此传感器可以用于机器人的测距、避障以及高级的路径规划,是机器视觉及其应用领域的不错选择。
技术规格
- 信号类型:模拟输出
- 探测距离:20-150cm
- 工作电压:4.5-5.5V
- 标准电流消耗:30 mA
- 接口类型:PH2.0-3P
- 最大尺寸:40x22x20 mm
连接图
分析图
模拟输出电压与反射物体的距离
示例代码
方案一
/* description:
The sample code is used to measure distance by GP2Y0A02YK IR ranger sensor.
VCC -- VCC
GND -- GND
Signal -- Analog 1
*/
int IRpin = 1; // analog pin for reading the IR sensor
void setup() {
Serial.begin(9600); // start the serial port
}
void loop() {
float volts = analogRead(IRpin)*0.0048828125; // value from sensor * (5/1024) - if running 3.3.volts then change 5 to 3.3
float distance = 65*pow(volts, -1.10); // worked out from graph 65 = theretical distance / (1/Volts)
Serial.println(distance); // print the distance
delay(100); // arbitary wait time.
}
方案二
/******** start code ********/
/*
* created 2013-07-26
* by lisper ([email protected])
* function test gp2y0a02yk, read value from A1
*
*/
//connect gp2y0a02 to A1
#define pin A1
void setup () {
Serial.begin (9600);
pinMode (pin, INPUT);
}
void loop () {
uint16_t value = analogRead (pin);
uint16_t range = get_gp2y0a02 (value);
Serial.println (value);
Serial.print (range);
Serial.println (" cm");
Serial.println ();
delay (500);
}
//return distance (cm)
uint16_t get_gp2y0a02 (uint16_t value) {
if (value < 70) value = 70;
return 12777.3/value-1.1; //(cm)
//return (62.5/(value/1023.0*5)-1.1); //(cm)
//return ((67870.0 / (value - 3.0)) - 40.0); //gp2d12 (mm)
}
/******** end code ********/
Go Shopping Sharp GP2Y0A02YK 红外测距传感器(SKU:SEN0013)
category: Product Manual category: TEL Series category: Modules category: source