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:
constRaspi=require('raspi-io') constfive=require('johnny-five') constboard=newfive.Board({ io:newRaspi() }) 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.