Created
July 13, 2017 22:35
-
-
Save nooitaf/68eae9faac6add0d2f85ee88634f6e6f to your computer and use it in GitHub Desktop.
johnny-five motozero example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "johnny-five": "^0.10.13", | |
// "raspi-io": "^8.0.1", | |
var Raspi = require('raspi-io'); | |
var five = require('johnny-five'); | |
var board = new five.Board({ | |
io: new Raspi({ | |
enableSoftPwm: true | |
}) | |
}); | |
board.on("ready", function() { | |
var motors = new five.Motors( | |
[ | |
// motor 1 | |
{ | |
pins: { | |
pwm: 5, | |
dir: 2, | |
enable: 21 | |
}, | |
invertPWM: true | |
}, | |
// motor 2 | |
{ | |
pins: { | |
pwm: 22, | |
dir: 3, | |
enable: 0 | |
}, | |
invertPWM: true | |
}, | |
// motor 3 | |
{ | |
pins: { | |
pwm: 4, | |
dir: 27, | |
enable: 26 | |
}, | |
invertPWM: true | |
}, | |
// motor 4 | |
{ | |
pins: { | |
pwm: 23, | |
dir: 1, | |
enable: 6 | |
}, | |
invertPWM: true | |
} | |
] | |
); | |
motors.disable() | |
motors.forward(255) | |
motors.enable(); | |
board.wait(1000, function() { | |
motors.reverse() | |
board.wait(1000, function() { | |
motors.stop() | |
}) | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment