The Johnny-Five motor object

The motor object in Johnny-Five allows us to easily control our motors without having to worry about communicating with the hat via the Pi. Let's code a test setup with the REPL before coding our project, to make sure everything is working.

Create a new project folder and, inside it, run the following:

npm init -y

And, create a file in the folder named motor-test.js. Start by requiring in Johnny-Five and Raspi-IO, instantiating your board object, and creating a board.on('ready') handler, as we usually do:

const Raspi = require('raspi-io')
const five = require('johnny-five')
const board = new five.Board({
io: new Raspi()
})

board.on('ready', () => {

})

Now, we're ready to set up our motor object, keeping in mind that we'll need to configure for our hat.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.115.155