forked from pubnub/pubnub-galileo-xyz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
38 lines (29 loc) · 729 Bytes
/
main.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
var mraa = require('mraa');
var PUBNUB = require('pubnub');
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console
var x = new mraa.Aio(0);
var y = new mraa.Aio(1);
var z = new mraa.Aio(2);
var xo = x.read();
var yo = y.read();
var zo = z.read();
var pubnub = PUBNUB.init({
publish_key: 'demo',
subscribe_key: 'demo'
});
setInterval(function(){
var xv = x.read() - xo;
var yv = y.read() - yo;
var zv = z.read() - zo;
console.log(xv, yv, zv);
pubnub.publish({
channel: 'pubnub-intel-gal-demo-xyz',
message: {
columns: [
['x', xv],
['y', yv],
['z', zv]
]
}
});
}, 1000);