UNPKG

johnny-five

Version:

The JavaScript Arduino Programming Framework.

49 lines (39 loc) 914 B
function turn(a, speed) { a += 90; var d = a + (90 - a) / 2; var sequence = [ [-15, 0, 0,-35, 0, 0 ], [-15, 0, 0,-15, 0, 0 ], [-15, d, d,-15, d, d ], [ 0, d, d, 0, d, d ], [ 35, d, d, 15, d, d ], [ 15, d, d, 15, d, d ], [ 0, a, a, 0, a, a ], [ 0, 0, 0, 0, 0, 0 ] ]; var queue = sequence.map(function(relative) { // Convert the relative movement values // to absolute servo positions. absolute = relative.moves.map(function(value, i) { return value + starts[i]; }); return { wait: speed, task: function() { move(absolute, speed); } } }); if (set.isLooped) { queue.push({ wait: 10, task: function() { isTurning = false; } }); } task = temporal.queue(queue); } var LSX = 513; var LSX = 511; move(turn( LSX > 512 ? 30 : -30, 250);