Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var tessel = require('tessel');
- var accellib = require('accel-mma84');
- var wifi = require('wifi-cc3000');
- var acellerometer = accellib.use(tessel.port.C);
- var http = require('http');
- wifi.connect({
- ssid: 'pubnub-ac',
- password: 'pubnub.com'
- }, function (err, res) {
- if (err) {
- console.log(err);
- process.exit(1);
- }
- console.log('IP: ' + res.ip);
- acellerometer.on('ready', function() {
- acellerometer.on('data', function (xyz) {
- var position = Math.max(0, Math.min(1, xyz[2] * 0.5));
- var req = http.request({
- host: '10.96.70.159',
- port: 80,
- path: '/',
- method: 'POST'
- });
- req.write(position.toString());
- req.end();
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement