Skip to content

Instantly share code, notes, and snippets.

@makenai
Created March 13, 2016 22:56
Show Gist options
  • Save makenai/1047a42855cde861532d to your computer and use it in GitHub Desktop.
Save makenai/1047a42855cde861532d to your computer and use it in GitHub Desktop.
Temporal queue plus servo timings.
var five = require("johnny-five");
var temporal = require('temporal');
var board = new five.Board({
debug: false
});
// Outputs:
// ---
// node testCase.js
// >> One
// ---
// (Then nothing)
// If you remove the timings from the servo.to() calls, it works fine.
board.on("ready", function() {
var servo = new five.Servo({
pin: 9,
startAt: 5
});
temporal.queue([
{
delay: 500,
task: function() {
console.log('One');
servo.to(20, 200);
}
},
{
delay: 500,
task: function() {
console.log('Two');
servo.to(5, 200);
}
},
{
delay: 500,
task: function() {
console.log('Three');
servo.to(20, 200);
}
},
{
delay: 500,
task: function() {
console.log('Four');
servo.to(5, 200);
}
}
]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment