-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathleapBlink.js
60 lines (41 loc) · 973 Bytes
/
leapBlink.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
// To run:
// $ node leapBlink.js
var frameCount = 0;
"use strict";
var HOSTNAME = "192.168.0.101";
var USERNAME = "82bf6d045f12856fa06cb642cbff0e";
var Cylon = require("cylon");
Cylon.robot({
name: "leapbot",
connections: {
leapmotion: { adaptor: "leapmotion" }
},
devices: {
leapmotion: { driver: "leapmotion" }
},
work: function(my) {
my.leapmotion.on('frame', function(frame) {
frameCount++;
if(frameCount % 40 != 0) {return;}
if (frame.hands.length > 0) {
console.log("Bulb ON")
Cylon.bulb4.turnOn();
} else {
console.log("Bulb OFF");
Cylon.bulb4.turnOff();
}
});
}
}).start();
Cylon.robot({
name: "huebot",
connections: {
hue: { adaptor: 'hue', host: HOSTNAME, username: USERNAME }
},
devices: {
bulb4: { driver: 'hue-light', lightId: 4}
},
work: function(my) {
}
}).start();
Cylon.bulb4 = Cylon.MCP.robots.huebot.devices.bulb4;