Permalink
Fetching contributors…
Cannot retrieve contributors at this time
82 lines (47 sloc) 1.28 KB

Robotic Claw

Run this example from the command line with:

node eg/claw.js
var five = require("johnny-five");
var board = new five.Board();

board.on("ready", function() {

  var claw = new five.Servo(9);
  var arm = five.Servo(10);
  var degrees = 10;
  var incrementer = 10;
  var last;

  this.loop(25, function() {

    if (degrees >= 180 || degrees === 0) {
      incrementer *= -1;
    }

    degrees += incrementer;

    if (degrees === 180) {
      if (!last || last === 90) {
        last = 180;
      } else {
        last = 90;
      }
      arm.to(last);
    }

    claw.to(degrees);
  });
});


Additional Notes

 

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.