Hardware Hacking with JavaScript

Hardware Hacking with JavaScript

Presented at WXG 2014

8ddbf811da78bb0daeeb3cacd7cf743f?s=128

Andrew Nesbitt

September 26, 2014
Tweet

Transcript

  1. 5.
  2. 6.
  3. 7.
  4. 9.
  5. 10.

    Advanced Mathematics Mechanical Engineering Digital Electronics Analogue Electronics Computer Science

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

    Advanced Mathematics Advanced Mathematics Advanced Mathematics Advanced Mathematics Advanced Mathematics

    Advanced Mathematics Advanced Mathematics Advanced Mathematics Observing Robots behind glass LEARNING ROBOTICS
  7. 18.
  8. 20.
  9. 21.

    EV3

  10. 22.
  11. 24.
  12. 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.
  13. 26.
  14. 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 };
  15. 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
 })
 });
 });

  16. 31.
  17. 32.
  18. 35.
  19. 36.
  20. 37.
  21. 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)
 }) 

  22. 41.
  23. 45.
  24. 46.
  25. 47.
  26. 48.
  27. 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
  28. 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();
 });
  29. 56.
  30. 57.
  31. 58.