Last active
December 14, 2015 22:11
-
-
Save chico/82a18bd2eb38287474f7 to your computer and use it in GitHub Desktop.
This file contains 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
var five = require('johnny-five') | |
var board = new five.Board() | |
var moveBase = function(board, base, cb) { | |
base.to(10, 2000) | |
board.wait(2500, function () { | |
base.to(170, 3000) | |
board.wait(3500, function () { | |
base.to(90, 1500) | |
board.wait(2000, function () { | |
cb(); | |
}); | |
}); | |
}); | |
} | |
var moveLeftDown = function(board, left, cb) { | |
left.to(10, 1000) | |
board.wait(1500, function () { | |
cb(); | |
}); | |
} | |
var moveLeftUp = function(board, left, cb) { | |
left.to(90, 1000) | |
board.wait(1500, function () { | |
cb(); | |
}); | |
} | |
var moveRight = function(board, right, cb) { | |
right.to(65, 1000) | |
board.wait(1500, function () { | |
right.to(135, 1500) | |
board.wait(2000, function () { | |
cb(); | |
}); | |
}); | |
} | |
var moveClaw = function(board, claw, cb) { | |
claw.to(45, 1000) | |
board.wait(2000, function () { | |
claw.center() | |
board.wait(1000, function () { | |
claw.to(45, 1000) | |
board.wait(2000, function () { | |
claw.stop() | |
claw.center() | |
cb() | |
}); | |
}); | |
}); | |
} | |
board.on('ready', function () { | |
var base = new five.Servo(11) | |
var claw = new five.Servo(6) | |
var left = new five.Servo(9) | |
var right = new five.Servo(10) | |
base.center() | |
claw.center() | |
right.center() | |
left.center() | |
moveBase(board, base, function() { | |
moveRight(board, right, function() { | |
moveLeftDown(board, left, function() { | |
moveClaw(board, claw, function() { | |
moveLeftUp(board, left, function() { | |
right.stop() | |
right.center() | |
}) | |
}); | |
}); | |
}); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment