Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. const EtherPortClient = require("etherport-client").EtherPortClient;
  2. const Firmata = require("firmata");
  3. const five = require("johnny-five");
  4.  
  5. const board = new five.Board({
  6. io: new Firmata(new EtherPortClient({
  7. host: "10.0.1.4", // CHANGE TO YOUR IP ADDRESS
  8. port: 3030
  9. }))
  10. });
  11.  
  12. board.on("ready", function() {
  13. var accelerometer = new five.Accelerometer({
  14. controller: "ADXL345",
  15. // Optionally set the range to one of
  16. // 2, 4, 8, 16 (±g)
  17. // Defaults to ±2g
  18. // range: ...
  19. });
  20.  
  21. accelerometer.on("change", function() {
  22. console.log("accelerometer");
  23. console.log(" x : ", this.x);
  24. console.log(" y : ", this.y);
  25. console.log(" z : ", this.z);
  26. console.log(" pitch : ", this.pitch);
  27. console.log(" roll : ", this.roll);
  28. console.log(" acceleration : ", this.acceleration);
  29. console.log(" inclination : ", this.inclination);
  30. console.log(" orientation : ", this.orientation);
  31. console.log("--------------------------------------");
  32. });
  33. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement