Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including arduino-distance-sensor-stream with all npm packages installed. Try it out:

var arduinoDistanceSensorStream = require("arduino-distance-sensor-stream")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

arduino-distance-sensor-stream v1.0.1

Get sensor data as stream

arduino-distance-sensor-stream

Get arduino proximity sensor data as a node stream

Usage

var ProximitySensor = require('../index.js');

new ProximitySensor({
        controller:'HCSR04',
        sample:50, //Sample every 50 ms (optional)
        unit:'in'  // cm or in (optional, default cm)
    }).pipe(process.stdout);

** Note **

Some sensor devices require a special Firmata loaded

Options

An object with:

{
    controller:'HCSR04',
    sample:50, //Sample every 50 ms (optional)
    unit:'cm'  // cm or in (optional, default cm)
}

Supported controllers

GP2Y0A21YK
GP2D120XJ00F
GP2Y0A02YK0F
GP2Y0A41SK0F
GP2Y0A21YK
GP2Y0A02YK0F
LV-MaxSonar-EZ
HRLV-MaxSonar-EZ0
XL-MaxSonar-EZ3
HC-SR04
HCSR04
SRF05
PARALLAXPING
SEEEDPING
GROVEPING
LIDAR-Lite

For an updated list and how to connect your Arduino Board check

https://github.com/rwaldron/johnny-five/wiki/Proximity

TODO:

Handle backpressure properly.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free