Advanced Servo

thisandagain edited this page Aug 26, 2012 · 4 revisions
Clone this wiki locally

Example

var phidget = require('phidget');

// Create a new servo object
var servo = new phidget.servo();

// Attach the servo device
servo.attach(function (err) {
    // Set the servo on pin "0" to engaged
    servo.setEngaged(0, true, function (err) {
        // Move the servo on pin "0" to 90 degrees
        // NOTE! The callback will not return until the servo has stopped
        servo.setPosition(0, 90, function (err) {
            // Move the servo on pin "0" to 90 degrees
            servo.setPosition(0, 180, function (err) {
                // Get the position of the servo on pin "0"
                servo.getPosition(0, function (err, pos) {
                    // It's done!
                });
            });
        });
    });
});

Methods

  • attach
  • close
  • setEngaged
  • getPosition
  • setPosition
  • getStopped

Properties

  • ready