forked from rwaldron/johnny-five
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservo-array.js
78 lines (61 loc) · 1.22 KB
/
servo-array.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
var five = require("../lib/johnny-five.js"),
board, array;
board = new five.Board();
board.on("ready", function() {
five.Servo({
pin: 9,
// Limit this servo to 170°
range: [ 0, 170 ]
});
five.Servo(10);
// Initialize a reference to all Servo instances
// five.Servo.Array()
// five.Servos()
array = new five.Servos();
// Inject the `servo` hardware into
// the Repl instance's context;
// allows direct command line access
board.repl.inject({
array: array
});
// Servo.Array API
// center()
//
// centers all servos to center of range
// defaults to 90°
//
// eg. array.center();
array.center();
// min()
//
// set all servos to the minimum degrees
// defaults to 0
//
// eg. array.min();
// max()
//
// set all servos to the maximum degrees
// defaults to 180
//
// eg. array.max();
// move( deg )
//
// set all servos to deg
//
// eg. array.move( deg );
// stop()
//
// stop all servos
//
// eg. array.stop();
// each( callbackFn )
//
// Execute callbackFn for each active servo instance
//
// eg.
// array.each(function( servo, index ) {
//
// `this` refers to the current servo instance
//
// });
});