Servo on pin 10
Servo connected to pin 10. Requires servo on pin that supports PWM (usually denoted by ~).
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));
});