Permalink
Fetching contributors…
Cannot retrieve contributors at this time
99 lines (57 sloc) 1.5 KB

Motor - l298 Breakout

Breadboard for "Motor - l298 Breakout"

docs/breadboard/motor-l298-breakout.png

Fritzing diagram: docs/breadboard/motor-l298-breakout.fzz

 

Run this example from the command line with:

node eg/motor-l298-breakout.js
var five = require("johnny-five"),
  board = new five.Board();

board.on("ready", function() {
  var motor;

  motor = new five.Motor({
    pins: {
      pwm: 8,
      dir: 9
    }
  });

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

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

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

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

    // demonstrate switching to reverse after 5 seconds
    board.wait(5000, function() {
      motor.reverse(50);
    });
  });

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

    // demonstrate stopping after 5 seconds
    board.wait(5000, function() {
      motor.stop();
    });
  });

  // set the motor going forward full speed
  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.