Hardware Hacking with JavaScript

Hardware Hacking with JavaScript

Presented at WXG 2014

8ddbf811da78bb0daeeb3cacd7cf743f?s=128

Andrew Nesbitt

September 26, 2014
Tweet

Transcript

  1. HARDWARE HACKING WITH JAVASCRIPT

  2. ANDREW NESBITT

  3. ELECTRONICS, ROBOTICS AND INTERNET OF THINGS FOR WEB DEVELOPERS

  4. MY ROBOT STORY

  5. None
  6. None
  7. None
  8. BEng Robotics & Automated Systems University of Plymouth

  9. None
  10. Advanced Mathematics Mechanical Engineering Digital Electronics Analogue Electronics Computer Science

    Control Theory Neural Networking Microprocessor Design Playing with Robots LEARNING ROBOTICS
  11. Advanced Mathematics Advanced Mathematics Advanced Mathematics Advanced Mathematics Advanced Mathematics

    Advanced Mathematics Advanced Mathematics Advanced Mathematics Observing Robots behind glass LEARNING ROBOTICS
  12. Hardware was expensive, complicated and not fun

  13. APIs Open Source Hardware Smart phones Dynamic Programming Languages GitHub

    Mobile Internet 3D Printing 2014
  14. HARDWARE HACKING WITH JAVASCRIPT

  15. WHY JAVASCRIPT?

  16. Any application that can be written in JavaScript, will eventually

    be written in JavaScript
  17. HIGH LEVEL ASYNC COMMUNITY INTERNET OF THINGS LOW BARRIERS

  18. None
  19. It's a UNIX system! I know this!

  20. LEGO

  21. EV3

  22. Demo Time

  23. ROBOT RABBIT FEEDER

  24. None
  25. Node.js is a platform built on Chrome's JavaScript runtime for

    easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
  26. None
  27. Server-side Javascript Asynchronous Runs on v8 from Chrome Perfect for

    network programs
  28. http://nodejs.org/download/ ! nodejs.org/download v0.10.32 $ node $ npm install ar-drone

  29. ! var Ev3 = require ("ev3-nodejs-bt");
 var Ev3_base = Ev3.base;


    
 var XboxController = require('xbox-controller');
 var xbox = new XboxController;
 
 var robot = new Ev3_base("/dev/tty.EV3-SerialPort");
 
 var maxAngle = 32768;
 var maxSpeed = 100;
 
 var speeds = { a: 0, b: 0, c: 0, d: 0 };
  30. ! robot.connect(function(){
 robot.start_program(function(ev3){
 var setSpeed = function(){
 var output =

    ev3.getOutputSequence(speeds.a,speeds.b,speeds.c,speeds.d);
 ev3.sp.write(output);
 }
 
 setInterval(setSpeed, 100)
 
 xbox.on('left:move', function(position){
 var x = -(position.x / maxAngle)*-maxSpeed
 var y = (position.y / maxAngle)*-maxSpeed
 
 var left = y-x
 var right = y+x
 
 speeds.b = left
 speeds.a = right
 })
 
 xbox.on('a:press', function(){
 speeds.d = 100
 })
 
 xbox.on('a:release', function(){
 speeds.d = 0
 })
 });
 });

  31. None
  32. None
  33. github.com/andrew/node-ev3-robot

  34. github.com/clebert/ev3

  35. None
  36. ARDUINO

  37. FIRMATA

  38. Cat Laser Toy

  39. Cat Laser Toy Rabbit | v

  40. ! var five = require("johnny-five"),
 board = new five.Board();
 


    function randomFromInterval(from,to){
 return Math.floor(Math.random()*(to-from+1)+from); 
 }
 
 board.on("ready", function() {
 var servoX = new five.Servo(10);
 var servoY = new five.Servo(9);
 var laser = new five.Led(8);
 
 laser.on()
 
 setInterval(function(){
 x = randomFromInterval(80, 120)
 y = randomFromInterval(95, 145)
 servoX.move(x)
 servoY.move(y)
 }, 400)
 }) 

  41. None
  42. hobbytronics.co.uk/sparkfun-inventors-kit-v3 Sparkfun Inventors Kit

  43. node-ardx.org

  44. JAVASCRIPT MICROCONTROLLERS

  45. None
  46. None
  47. None
  48. None
  49. £70 £21 £30 £40 Lua based Tiny-js Node.js or browser

    Node.js Plug and play Hacker friendly Tiny computer All the ports
  50. NODECOPTER

  51. PROGRAMMATIC FLYING ROBOTS

  52. HD Camera Down-facing camera Gyroscope Wifi 1GHz CPU Linux Accelerometer

    Magnetometer Ultrasound
  53. GITHUB.COM/FELIXGE/NODE-AR-DRONE

  54. ! var arDrone = require('ar-drone');
 var client = arDrone.createClient(); 


    
 client.takeoff();
 
 client
 .after(5000, function() {
 this.clockwise(0.5);
 })
 .after(3000, function() {
 this.animate('flipLeft', 15);
 })
 .after(1000, function() {
 this.stop();
 this.land();
 });
  55. shama.github.com/voxel-drone

  56. DEMO TIME

  57. WARNING

  58. QR CODER

  59. Dance Dance Drone

  60. github.com/eschnou/ardrone-webflight

  61. Quadcopters as a Service

  62. ROBOT LASER PONG

  63. WRAPPING UP

  64. STAY ON THE EDGE OF YOUR COMFORT ZONE

  65. BRING EVERYTHING GREAT ABOUT THE INTERNET TO THE REAL WORLD

  66. GO FORTH AND HACK

  67. No animals were harmed in the making of this presentation

    Thanks!
  68. github.com/andrew Thanks!

  69. Thanks! @teabass