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

motor-sparkfun-edison-hbridge.png

Fritzing diagram: motor-sparkfun-edison-hbridge.fzz

 

Run this example from the command line with:

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

board.on("ready", () => {
  const config = Motor.SHIELD_CONFIGS.SPARKFUN_DUAL_HBRIDGE_EDISON_BLOCK;
  const motor = new Motor(config.B);

  board.repl.inject({
    motor
  });

  motor.on("stop", () => {
    console.log(`automated stop on timer: ${Date.now()}`);
  });

  motor.on("forward", () => {
    console.log(`forward: ${Date.now()}`);

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

  motor.on("enable", () => {
    console.log(`motor enabled: ${Date.now()}`);

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

  motor.on("disable", () => {
    console.log(`motor disabled: ${Date.now()}`);
  });


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

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

 

Component Classes in this example:

Hi! The Johnny-Five community is building new projects every day. We made this newsletter to tell you about what's new, what's good, and what's next for Open Source robotics. Join us in exploring what we can make together.

Fork me on GitHub