-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.js
53 lines (46 loc) · 957 Bytes
/
example.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
var Kryten, kryten, testOptions;
Kryten = require('./index.js');
var kryten = new Kryten({});
testOptions = {
'autoDetect': true,
'port': '',
'interval': '500',
'components': [
{
'name': 'Led_Pin_13',
'action': 'digitalWrite',
'pin': '13'
}, {
'name': 'some_sensor',
'action': 'analogRead',
'pin': '3'
}, {
'name': 'Servo1',
'action': 'servo',
'pin': '6'
}
]
};
kryten.configure(testOptions);
kryten.on('ready', function() {
var state;
console.log('ready to go dog');
kryten.on('data', function(data) {
return console.log(data);
});
kryten.on('config', function(schema) {
return console.log(schema);
});
state = '1';
return setInterval(function() {
kryten.onMessage({
component: 'Led_Pin_13',
state: state
});
if (state === '1') {
return state = '0';
} else {
return state = '1';
}
}, 1000);
});