-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest3.js
More file actions
37 lines (36 loc) · 755 Bytes
/
Copy pathtest3.js
File metadata and controls
37 lines (36 loc) · 755 Bytes
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
var sphero = require("sphero");
var orb = sphero("COM7"); // 自分の Sphero の ID に置き換える
orb.connect(function() {
function setSpheroTimeout(fn, time) {
setTimeout(function() {
orb.ping(function() {
fn();
});
}, time);
}
function a() {
orb.color("blue");
orb.roll(100, 0);
setTimeout(b, 100);
}
function b() {
orb.color("red");
orb.roll(0, 0);
setSpheroTimeout(c, 100);
}
function c() {
orb.color("green");
orb.roll(100, 180);
setTimeout(d, 100);
}
function d() {
orb.color("yellow");
orb.roll(0, 180);
setSpheroTimeout(a, 100);
}
orb.color("black");
setTimeout(function() {
isCheckSphero = true;
streamCallback = a;
}, 100);
});