Skip to content

Instantly share code, notes, and snippets.

@nooitaf
Created July 13, 2017 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nooitaf/68eae9faac6add0d2f85ee88634f6e6f to your computer and use it in GitHub Desktop.
Save nooitaf/68eae9faac6add0d2f85ee88634f6e6f to your computer and use it in GitHub Desktop.
johnny-five motozero example
// "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