-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
39 lines (35 loc) · 985 Bytes
/
app.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
var Cylon = require('cylon');
Cylon.robot({
connections: [{
name: 'arduino',
adaptor: 'firmata',
// port: '/dev/tty.usbserial-A900N2ET'
port: '/dev/tty.usbserial-A800HFW6'
}, {
name: 'skynet',
adaptor: 'skynet',
uuid: "96ee6c21-ec85-11e3-995a-b7667747c514",
token: "00a287blzbrwl8frqbdaxhhw7j9bpgb9"
}],
device: {
name: 'led',
driver: 'led',
pin: 13,
connection: 'arduino'
},
work: function(my) {
Cylon.Logger.info('Started');
my.skynet.on('message', function(data) {
var message = JSON.parse(data.payload);
Cylon.Logger.info(message);
if(message.red == 'on') {
Cylon.Logger.info('Turning on led');
my.led.turnOn();
}
else if(message.red == 'off') {
Cylon.Logger.info('Turning off led');
my.led.turnOff();
}
});
}
}).start();