Run this example from the command line with:

node eg/servo-multi-turn.js
const {Board, Servo} = require("johnny-five");
const board = new Board();

board.on("ready", () => {
  const servo = new Servo({
    pin: 10,
    // Cheapo servo has limited PWM range
    pwmRange: [600, 2370],
    // This multi-turn servo can turn 2430 degrees or 6.75 revolutions
    deviceRange: [0, 2430]
  });

  // Add servo to REPL (optional)
  board.repl.inject({
    servo
  });


  // Servo API

  // min()
  //
  // move the servo to its minimum position
  //
  // eg. servo.min();

  // max()
  //
  // move the servo to its maximum position of 6.75 turns from the minimum
  //
  // eg. servo.max();

  // center()
  //
  // centers the servo at 3 3/8 turns from the minimum
  //
  // servo.center();

  // to( deg )
  //
  // Moves the servo to 2 whole turns from the minimum
  //
  // servo.to( 720 );

});

 

Component Classes in this example:

Hi! The Johnny-Five community is building new projects every day. We made this newsletter to tell you about what's new, what's good, and what's next for Open Source robotics. Join us in exploring what we can make together.

Fork me on GitHub