UNPKG

johnny-five

Version:

The JavaScript Arduino Programming Framework.

64 lines (51 loc) 1.18 kB
var five = require("../lib/johnny-five.js"), board, servo; board = new five.Board(); board.on("ready", function() { // Create a new `servo` hardware instance. servo = new five.Servo(10); // Inject the `servo` hardware into // the Repl instance's context; // allows direct command line access // board.repl.inject({ // servo: servo // }); // Servo API // min() // // set the servo to the minimum degrees // defaults to 0 // // eg. servo.min(); // max() // // set the servo to the maximum degrees // defaults to 180 // // eg. servo.max(); // center() // // centers the servo to 90° // servo.center(); // move( deg ) // // Moves the servo to position by degrees // // servo.to( 90 ); // sweep( obj ) // // Perform a min-max cycling servo sweep (defaults to 0-180) // optionally accepts an object of sweep settings: // { // lapse: time in milliseconds to wait between moves // defaults to 500ms // degrees: distance in degrees to move // defaults to 10° // } // // servo.sweep(); }); // References // // http://servocity.com/html/hs-7980th_servo.html