Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hardware Hacking with JavaScript

Hardware Hacking with JavaScript

Full repo of code and slides here: https://github.com/andrew/jquery-uk

Andrew Nesbitt

May 16, 2014
Tweet

More Decks by Andrew Nesbitt

Other Decks in Programming

Transcript

  1. jQuery UK
    16 May 2014
    1 / 73

    View Slide

  2. Andrew Nesbitt
    Bath, UK
    @teabass
    GitHub
    2 / 73

    View Slide

  3. Francis Gulotta
    New York City, USA
    @reconbot
    Wizard Development
    3 / 73

    View Slide

  4. Hardware Hacking with JavaScript
    4 / 73

    View Slide

  5. Hardware Hacking?
    5 / 73

    View Slide

  6. Hardware Hacking?
    Combining electronics and physical components with code
    6 / 73

    View Slide

  7. Hardware Hacking?
    Combining electronics and physical components with code
    Making real things and controlling them with software
    7 / 73

    View Slide

  8. Hardware Hacking?
    Combining electronics and physical components with code
    Making real things and controlling them with software
    Building things with your hands
    8 / 73

    View Slide

  9. Hardware Hacking?
    Combining electronics and physical components with code
    Making real things and controlling them with software
    Building things with your hands
    Joining the Maker Movement
    9 / 73

    View Slide

  10. Why JavaScript?
    10 / 73

    View Slide

  11. Why JavaScript?
    Hardware demands asynchronous software
    11 / 73

    View Slide

  12. Why JavaScript?
    Hardware demands asynchronous software
    Huge and diverse community
    12 / 73

    View Slide

  13. Why JavaScript?
    Hardware demands asynchronous software
    Huge and diverse community
    Lowering the barriers to entry
    13 / 73

    View Slide

  14. Why yes, JavaScript!
    Hardware demands asynchronous software
    Huge and diverse community
    Lowering the barriers to entry
    JavaScript is the language of the web
    14 / 73

    View Slide

  15. Internet of Things
    15 / 73

    View Slide

  16. Internet of Things
    Bridging hardware devices and online services
    16 / 73

    View Slide

  17. Internet of Things
    Bridging hardware devices and online services
    Treating hardware as an API
    17 / 73

    View Slide

  18. Internet of Things
    Bridging hardware devices and online services
    Treating hardware as an API
    Interconnecting all kinds of hardware
    18 / 73

    View Slide

  19. Internet of Things
    Bridging hardware devices and online services
    Treating hardware as an API
    Interconnecting all kinds of hardware
    Mashing up software and hardware
    19 / 73

    View Slide

  20. Demo Driven Development
    20 / 73

    View Slide

  21. 21 / 73

    View Slide

  22. Makey Makey
    22 / 73

    View Slide

  23. Makey Makey
    keys = {
    87: 'W',
    65: 'A',
    83: 'S',
    68: 'D'
    }
    $(document).keydown(function (e) {
    console.log(keys[e.which])
    });
    23 / 73

    View Slide

  24. Emoji Fruit Piano
    24 / 73

    View Slide

  25. Emoji Fruit Piano
    Patent Pending
    25 / 73

    View Slide

  26. 26 / 73

    View Slide

  27. Emoji Fruit Piano Demo
    27 / 73

    View Slide

  28. 28 / 73

    View Slide

  29. Spark Core
    29 / 73

    View Slide

  30. Spark.io
    Open source microcontroller
    Arduino compatible
    Wifi enabled
    Cloud certified®
    30 / 73

    View Slide

  31. The Internet Connected Hat
    31 / 73

    View Slide

  32. The Internet Connected Hat
    Patent Pending
    32 / 73

    View Slide

  33. 33 / 73

    View Slide

  34. Spark Core
    34 / 73

    View Slide

  35. Spark Core
    npm install sparky
    var Sparky = require('sparky')
    var core = new Sparky({
    deviceId: 'your device id',
    token: 'your access token',
    })
    core.digitalWrite('D7', 'HIGH');
    core.digitalRead('D0', function(val){
    console.log(val)
    });
    35 / 73

    View Slide

  36. 36 / 73

    View Slide

  37. 37 / 73

    View Slide

  38. Arduino Uno
    38 / 73

    View Slide

  39. Johnny Five
    39 / 73

    View Slide

  40. 40 / 73

    View Slide

  41. Johnny-Five is jQuery for robots
    41 / 73

    View Slide

  42. Johnny-Five is jQuery for the
    physical world
    42 / 73

    View Slide

  43. Johnny-Five
    Supports over 99 hardware devices
    Started by Rick Waldren now has over
    61 Contributers
    Most active JavaScript Robot
    Community
    43 / 73

    View Slide

  44. "A blinking light is the hello world of
    robotics."
    -Sara Chipps
    44 / 73

    View Slide

  45. Blink for Arduino
    int led = 13;
    // the setup routine runs once when you press reset:
    void setup() {
    // initialize the digital pin as an output.
    pinMode(led, OUTPUT);
    }
    // the loop routine runs over and over again forever:
    void loop() {
    digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
    delay(1000); // wait for a second
    digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
    delay(1000); // wait for a second
    }
    45 / 73

    View Slide

  46. Blink for Johnny Five
    var five = require("johnny-five");
    var board = new five.Board();
    // Connect to the arudino
    board.on("ready", function() {
    // Create a new Led object on pin 13
    var led = new five.Led(13);
    led.blink(); // blink!
    });
    46 / 73

    View Slide

  47. Das Blinkenlights
    47 / 73

    View Slide

  48. 48 / 73

    View Slide

  49. ED 209
    var ED = require('johhny-five/eg/ed.js');
    // Create a new Enforcer Droid
    var ed209 = new ED({
    // assign servos
    right: { hip: 9, foot: 11 },
    left: { hip: 10, foot: 12 }
    });
    // Stand upright!
    ed209.attn();
    // Walk forward!
    ed209.fwd();
    // Dance!
    ed209.dance();
    // another Rick Waldron creation
    49 / 73

    View Slide

  50. ED 209
    50 / 73

    View Slide

  51. Parrot AR Drone 2.0
    51 / 73

    View Slide

  52. 52 / 73

    View Slide

  53. AR Drone
    npm install ar-drone
    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();
    }); 53 / 73

    View Slide

  54. 54 / 73

    View Slide

  55. 55 / 73

    View Slide

  56. High-tech Observation &
    Orientation Device Interaction Enabler
    56 / 73

    View Slide

  57. High-tech Observation &
    Orientation Device Interaction Enabler
    H.O.O.D.I.E
    57 / 73

    View Slide

  58. High-tech Observation &
    Orientation Device Interaction Enabler
    H.O.O.D.I.E
    Patent Pending
    58 / 73

    View Slide

  59. 59 / 73

    View Slide

  60. 60 / 73

    View Slide

  61. H.O.O.D.I.E
    // we're already connected to the drone and arduino
    var button = new five.Button(7);
    var leftYFlexSensor = new five.Sensor("A0");
    var rightYFlexSensor = new five.Sensor("A1");
    var leftZFlexSensor = new five.Sensor("A2");
    var rightZFlexSensor = new five.Sensor("A3");
    // push the button to turn on flying
    button.on("up", function() {
    toggleFlying();
    });
    61 / 73

    View Slide

  62. H.O.O.D.I.E
    // Map the flex sensors to both the drone and the VR simulation
    leftYFlexSensor.on("read", function(err, value){
    var a= five.Fn.map(value, 100, 500, -90, 90);
    leftY = five.Fn.constrain(a, -80, 80);
    io.sockets.emit('leftY', { angle: leftY, value: value });
    move();
    });
    rightZFlexSensor.on("read", function(err, value){
    var a = five.Fn.map(value, 500, 200, -60, 60);
    rightZ = five.Fn.constrain(a, -60, 60);
    io.sockets.emit('rightZ', { angle: rightZ, value: value });
    move();
    });
    62 / 73

    View Slide

  63. 63 / 73

    View Slide

  64. Wrapping up
    As web developers, you are in the perfect position for the future of internet
    connect devices.
    64 / 73

    View Slide

  65. Wrapping up
    As web developers, you are in the perfect position for the future of internet
    connect devices.
    This new breed of hardware and software brings jQuery-like levels of accessibility
    to Hardware Hacking.
    65 / 73

    View Slide

  66. Wrapping up
    As web developers, you are in the perfect position for the future of internet
    connect devices.
    This new breed of hardware and software brings jQuery-like levels of accessibility
    to Hardware Hacking.
    Making things with you hands is incredibly rewarding
    66 / 73

    View Slide

  67. 67 / 73

    View Slide

  68. NodeBots
    Any robot controlled by Node.js (or JS in general)
    Coined by Chris Willams in "Rise of JS Robotics"
    Cool Logo
    68 / 73

    View Slide

  69. NodeBots Events
    Chapters all over the world (4 countries, 6 cities)
    Reach out to Oli Evans (@olizilla) about NodeBots London
    Start a new chapter near you with just a github pull request?
    Nodebots are better with friends
    69 / 73

    View Slide

  70. 70 / 73

    View Slide

  71. NodeCopter
    AR Drones controlled with nodejs
    Hackdays with flying robots
    Community event (affordable & inclusive)
    Learning, sharing, fun and being nice to each other
    71 / 73

    View Slide

  72. Get out the and start hacking!
    72 / 73

    View Slide

  73. Thanks
    @teabass @reconbot
    github.com/andrew/jquery-uk
    73 / 73

    View Slide