August 2018
Beginner to intermediate
214 pages
6h 39m
English
Create a new file in your project folder called my-first-animation.js and create the normal boilerplate: require in Johnny-Five and Raspi-IO, create your Board object, and create the board.on('ready') function:
const Raspi = require('raspi-io')const five = require('johnny-five')const board = new five.Board({ io: new Raspi()})board.on('ready', () => {})
Then, inside the board.on('ready') handler, construct our two Servo objects on pin 0 and pin 1 of our PWM hat:
let servoOne = new five.Servo({ controller: "PCA9685", pin: 0})let servoTwo = new five.Servo({ controller: "PCA9685", pin: 1})
And create a Servos object containing our servos:
let servos = new five.Servos([servoOne, servoTwo])
Now that we have a group ...
Read now
Unlock full access