Permalink
Fetching contributors…
Cannot retrieve contributors at this time
100 lines (57 sloc) 1.73 KB

Motor - Sparkfun Dual H-bridge Edison Block

Breadboard for "Motor - Sparkfun Dual H-bridge Edison Block"

docs/breadboard/motor-sparkfun-edison-hbridge.png

Fritzing diagram: docs/breadboard/motor-sparkfun-edison-hbridge.fzz

 

Run this example from the command line with:

node eg/motor-sparkfun-edison-hbridge.js
var five = require("johnny-five");
var Edison = require("galileo-io");
var board = new five.Board({
  io: new Edison()
});

board.on("ready", function() {
  var config = five.Motor.SHIELD_CONFIGS.SPARKFUN_DUAL_HBRIDGE_EDISON_BLOCK;
  var motor = new five.Motor(config.B);

  board.repl.inject({
    motor: motor
  });

  motor.on("stop", function() {
    console.log("automated stop on timer", Date.now());
  });

  motor.on("forward", function() {
    console.log("forward", Date.now());

    // enable the motor after 2 seconds
    board.wait(2000, function() {
      motor.enable();
    });
  });

  motor.on("enable", function() {
    console.log("motor enabled", Date.now());

    // enable the motor after 2 seconds
    board.wait(2000, function() {
      motor.stop();
    });
  });

  motor.on("disable", function() {
    console.log("motor disabled", Date.now());
  });


  // // disable the motor
  motor.disable();

  // set the motor going forward full speed (nothing happen)
  motor.forward(255);
});

 

License

Copyright (c) 2012-2014 Rick Waldron waldron.rick@gmail.com Licensed under the MIT license. Copyright (c) 2015-2018 The Johnny-Five Contributors Licensed under the MIT license.