Advertisement
Guest User

Untitled

a guest
Sep 30th, 2014
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. var tessel = require('tessel');
  2. var accellib = require('accel-mma84');
  3. var wifi = require('wifi-cc3000');
  4. var acellerometer = accellib.use(tessel.port.C);
  5. var http = require('http');
  6.  
  7. wifi.connect({
  8. ssid: 'pubnub-ac',
  9. password: 'pubnub.com'
  10. }, function (err, res) {
  11. if (err) {
  12. console.log(err);
  13. process.exit(1);
  14. }
  15. console.log('IP: ' + res.ip);
  16. acellerometer.on('ready', function() {
  17. acellerometer.on('data', function (xyz) {
  18. var position = Math.max(0, Math.min(1, xyz[2] * 0.5));
  19. var req = http.request({
  20. host: '10.96.70.159',
  21. port: 80,
  22. path: '/',
  23. method: 'POST'
  24. });
  25. req.write(position.toString());
  26. req.end();
  27. });
  28. });
  29. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement