Now that we have one servo up and running, we're going to wire up a second one and use the REPL to explore the Johnny-Five Servos object, which is meant to help control several servos at once.
First, let's wire up our second servo.
Take the second servo, figure out which side is ground, put that one on the bottom, and slide the three-pin socket over the pins in the second column (pin 1):
Now that we've wired up a second servo, let's start coding our Johnny-Five servos object!
The Johnny-Five servos object is meant to help you group servos in ways that make sense for projects with many servos, such as hexapods with six legs, each containing multiple servos.
You can create a Servos
object in a few different ways; the way we will use is to pass an array of constructed servo
objects:
let servos=newfive.Servos([servoOne,servoTwo])
This is where the magic happens—now that our servo
objects are grouped in a...