-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathold.js
More file actions
47 lines (38 loc) · 1.07 KB
/
Copy pathold.js
File metadata and controls
47 lines (38 loc) · 1.07 KB
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
var tessel = require('tessel');
var http = require('http');
var options = {
hostname: '192.168.1.198',
port: 80,
path: '/api/newdeveloper/lights/',
method: 'GET'
};
var req = http.request(options, function(res) {
console.log('STATUS: ' + res.statusCode);
// console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: ' + chunk.length);
});
});
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
// write data to request body
// req.write('data\n');
// req.write('data\n');
req.end();
var port = process.argv[2] || 'A';
console.log("Connecting to accelerometer on port", port);
// Accelerometer
var accel = require('accel-mma84').connect(tessel.port(port));
// Initialize the accelerometer.
accel.on('connected', function () {
// Loop forever.
setInterval(function () {
accel.getAcceleration(function (err, xyz) {
console.log("x:", xyz[0].toFixed(2),
"y:", xyz[1].toFixed(2),
"z:", xyz[2].toFixed(2));
});
}, 500);
});