How to use the johnny-five.Proximity function in johnny-five

To help you get started, we’ve selected a few johnny-five examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fivdi / pi-io / example / hc-sr04-proximity-two-pin.js View on Github external
board.on('ready', function() {
  const proximity = new five.Proximity({
    controller: PiIO.HCSR04, // Custom controller
    triggerPin: 'GPIO23',
    echoPin: 'GPIO24'
  });

  proximity.on('change', function() {
    console.log('cm: ', this.cm);
  });
});
github nodebotsau / simplebot / examples / parking.js View on Github external
board.on("ready", function() {

    //Create new Ping and show distance on change
    var ping = new five.Proximity({
        pin: 7,
        freq: 200,
        controller: "HCSR04"
    });

    var piezo = new five.Piezo(11); // leostick piezo

    var intervalID = 0;

    ping.on("change", function( err, value ) {

        console.log('Object is ' + this.cm + ' cm away');
        // now we do a callback on the interval of the centimetres thus
        // shorter centimetres means less interval before calling the tone command
        clearInterval(intervalID);
        if (this.cm > 4) {  // this is arbitrary to stop the conflicts with tone.
github sayanee / talks / web-sensors / code / 9-proximity.js View on Github external
board.on('ready', function() {
  var proximity = new five.Proximity({
    controller: 'HCSR04',
    pin: 7 // Digital pin 7
  })

  proximity.on('data', function() {
    console.log(this.cm + ' cm at ' + new Date())
    // noisy data? You can use a smoothing algorithm:
    // http://stackoverflow.com/a/3761318/496797
  })
})
github nodebotsau / simplebot / examples / avoidance.js View on Github external
board.on("ready", function() {

    var left_wheel = new five.Servo.Continuous(9);
    var right_wheel = new five.Servo.Continuous(8);

    var controller = new Controller({
        left: left_wheel,
        right: right_wheel,
        lstop: 90, // use these to set the stop value of the servo
        rstop: 90,
    });

    // Create new Ping and use to avoid collisions.

    console.log('Initialising Range Finder');
    var ping = new five.Proximity({
        pin: 10,
        freq: 200,
        controller: "HCSR04"
    });

    ping.on("change", function( err, value ) {

        if (this.cm < range) {
            console.log('WARNING: Collision avoidance activated at: ' + this.cm + ' cm');
            left_wheel.to(controller.LSTOPVAL);
            right_wheel.to(controller.RSTOPVAL);
        }

    });
});
github fivdi / pi-io / example / hc-sr04-proximity.js View on Github external
board.on('ready', function() {
  const proximity = new five.Proximity({
    controller: 'HCSR04',
    pin: 'GPIO25'
  });

  proximity.on('data', function() {
    console.log('cm: ', this.cm);
  });
});
github nodebotsau / simplebot / examples / SimpleBotShield / ping.js View on Github external
board.on("ready", function() {

    //Create new Ping and show distance on change
    var ping = new five.Proximity({
        pin: 8,
        controller: "HCSR04",
        freq: 200,
    });

    ping.on("change", function( err, value ) {

        console.log('Object is ' + this.cm + ' cm away');
        console.log('Object is ' + this.inches + ' inches away');
    });
});
github Makeblock-official / mbot_nodebots / examples / sonar.js View on Github external
board.on("ready", function() {
  var proximity = new five.Proximity({
    freq: 1000,
    controller: "HCSR04",
    pin: 10
  });

  proximity.on("data", function() {
    console.log("inches: ", this.inches);
    console.log("cm: ", this.cm);
  });
});

johnny-five

The JavaScript Robotics and Hardware Programming Framework. Use with: Arduino (all models), Electric Imp, Beagle Bone, Intel Galileo & Edison, Linino One, Pinoccio, pcDuino3, Raspberry Pi, Particle/Spark Core & Photon, Tessel 2, TI Launchpad and more!

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis