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

Transcript

73 slides
  1. Hardware Hacking? Combining electronics and physical components with code Making

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

    real things and controlling them with software Building things with your hands 8 / 73
  3. 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
  4. 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
  5. Internet of Things Bridging hardware devices and online services Treating

    hardware as an API Interconnecting all kinds of hardware 18 / 73
  6. 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
  7. Makey Makey keys = { 87: 'W', 65: 'A', 83:

    'S', 68: 'D' } $(document).keydown(function (e) { console.log(keys[e.which]) }); 23 / 73
  8. 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
  9. Johnny-Five Supports over 99 hardware devices Started by Rick Waldren

    now has over 61 Contributers Most active JavaScript Robot Community 43 / 73
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. Wrapping up As web developers, you are in the perfect

    position for the future of internet connect devices. 64 / 73
  17. 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
  18. 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
  19. NodeBots Any robot controlled by Node.js (or JS in general)

    Coined by Chris Willams in "Rise of JS Robotics" Cool Logo 68 / 73
  20. 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
  21. 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

More Decks by Andrew Nesbitt

Other Decks in Programming