obniz Parts Library

Grove_DistanceSensor

GitHub
Grove_DistanceSensor
Usable Devices :
obniz_board
m5stickc
Found at :

Grove_DistanceSensor

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

photo of wired

wired(obniz, {[signal, vcc, gnd, grove]})

connect to the obniz device.
yellow, red and black wires correspond to signal, vcc and gnd respectively.

name type required default description
vcc number(obniz Board io) no   Power Supply
gnd number(obniz Board io) no   Power Supply
signal number(obniz Board io) no   signal output pin
grove object no   grove interface object if a device has
// Javascript Example
let sensor = obniz.wired("Grove_DistanceSensor", {grove: obniz.grove0});

start(callback(distance))

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

// Javascript Example
let sensor = obniz.wired("Grove_DistanceSensor", {grove: obniz.grove0});
sensor.start(function( distance ){
  console.log("distance " + distance + " mm")
})

[await] getWait()

Measure distance once.

// Javascript Example
let sensor = obniz.wired("Grove_DistanceSensor", {grove: obniz.grove0});

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
let sensor = obniz.wired("Grove_DistanceSensor", {grove: obniz.grove0});
sensor.unit("inch")
sensor.start(function( distance ){
  console.log("distance " + distance + " inch")
})

Supported from: obniz.js 3.7.0

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