GP2Y0A21YK0F

Infrared Distance Measurement Unit.
This unit output voltage regarding measured distance.

photo of wired

photo of wired

wired(obniz, {vcc, gnd, signal})

photo of wired

// Javascript Example
var sensor = obniz.wired("GP2Y0A21YK0F", {vcc:0, gnd:1, signal:2})
sensor.start(function( distance ){
  console.log("distance " + distance + " mm")
})

start(callback(distance))

measure distance continurously.
Callback will be called when distance changed.
default return unit is "mm". change by calling .unit()

// Javascript Example
var sensor = obniz.wired("GP2Y0A21YK0F", {vcc:0, gnd:1, signal:2})
sensor.start(function( distance ){
  console.log("distance " + distance + " mm")
})

[await] getWait()

Measure distance once.

// Javascript Example
var sensor = obniz.wired("GP2Y0A21YK0F", {vcc:0, gnd:1, signal:2})

while (1) {
  var val = await sensor.getWait();
  console.log("distance " + val);
  await obniz.wait(1000);
}

unit(unit)

change unit

  1. "mm"(default)
  2. "inch"

are available

// Javascript Example
var sensor = obniz.wired("GP2Y0A21YK0F", {vcc:0, gnd:1, signal:2})
sensor.unit("inch")
sensor.start(function( distance ){
  console.log("distance " + distance + " inch")
})


Found at :




You will Get in Few Days

Circuit for Starter “obniz Board” is available on Amazon and other online stores.
You can get it at below

Our products and resellers

Forum

Visit our developer’s forum to discuss and discover technologies.

Forum

Contact

Feel free to contact out support and technical team.

Contact us