Servo on pin 10

Servo connected to pin 10. Requires servo on pin that supports PWM (usually denoted by ~).

servo.png

Fritzing diagram: servo.fzz

 

Run this example from the command line with:

node eg/servo-prompt.js
const {Board, Servo} = require("johnny-five");
const readline = require("readline");

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

const board = new Board();

board.on("ready", () => {
  const servo = new Servo(10);

  rl.setPrompt("SERVO TEST (0-180)> ");
  rl.prompt();

  rl.on("line", (line) => {
    servo.to(+line.trim());
    rl.prompt();
  }).on("close", () => process.exit(0));
});

 

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