-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathj5.js
64 lines (52 loc) · 1.32 KB
/
j5.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
var five = require("johnny-five");
var board = new five.Board();
board.on("ready", function() {
var servo = new five.Servo(10);
// Servo alternate constructor with options
/*
var servo = new five.Servo({
id: "MyServo", // User defined id
pin: 10, // Which pin is it attached to?
type: "standard", // Default: "standard". Use "continuous" for continuous rotation servos
range: [0,180], // Default: 0-180
fps: 100, // Used to calculate rate of movement between positions
invert: false, // Invert all specified positions
startAt: 90, // Immediately move to a degree
center: true, // overrides startAt if true and moves the servo to the center of the range
});
*/
// Add servo to REPL (optional)
this.repl.inject({
servo: servo
});
// Servo API
// min()
//
// set the servo to the minimum degrees
// defaults to 0
//
// eg. servo.min();
// max()
//
// set the servo to the maximum degrees
// defaults to 180
//
// eg. servo.max();
// center()
//
// centers the servo to 90°
//
// servo.center();
// to( deg )
//
// Moves the servo to position by degrees
//
// servo.to( 90 );
// step( deg )
//
// step all servos by deg
//
// eg. array.step( -20 );
// servo.to(50);
servo.sweep()
});