You’ll need a couple of things:
- Adafruit Huzzah Feather
- Adafruit 16-Channel 12-bit PWM Servo Driver -I2C
- Pack of Micro Servos
- Cardboard
- Glue Gun
On the coding side, we’ll use Johnny 5, React, and Socket.IO. An amazing getting started article and starter repo has been created by Sam Julien. His example grabs data from a temperature sensor and displays it on a locally hosted page.Find it on his site: http://www.samjulien.com/johnny-feather/. Fortunately, sending data to the feather is just as easy.
Once you set up your environment and have the Huzzah setup with the Arduino Firmata protocol, communicate with the servos with the help of Johnny Five and Socket.IO
In device.js(server side) set up your servos:
var servoA = new five.Servo({
address: 0x40,
controller: “PCA9685”,
range: [0, 180],
pin: 0, });
and the socket:
socket.on(‘customEvent’, function (data) {
var degreeChange = data.degreeChange;
servoA.to(degreeChange); });
In app.js emit the customEvent:
socket.emit(‘customEvent’, {degreeChange:50});