johnny-five-electron
Version:
Temporary fork to support Electron (to be deprecated)
65 lines (50 loc) • 1.03 kB
JavaScript
var five = require("../lib/johnny-five.js");
var board = new five.Board();
board.on("ready", function() {
// Initialize a Servo collection
var servos = new five.Servos([9, 10]);
servos.center();
// Inject the `servo` hardware into
// the Repl instance's context;
// allows direct command line access
this.repl.inject({
servos: servos
});
// min()
//
// set all servos to the minimum degrees
// defaults to 0
//
// eg. servos.min();
// max()
//
// set all servos to the maximum degrees
// defaults to 180
//
// eg. servos.max();
// to( deg )
//
// set all servos to deg
//
// eg. servos.to( deg );
// step( deg )
//
// step all servos by deg
//
// eg. servos.step( -20 );
// stop()
//
// stop all servos
//
// eg. servos.stop();
// each( callbackFn )
//
// Execute callbackFn for each active servo instance
//
// eg.
// servos.each(function( servo, index ) {
//
// `this` refers to the current servo instance
//
// });
});