Learning how to Tinker

Learning how to Tinker

Hardware hacking for web developers.

Presented at Hybrid Conf 2014

8ddbf811da78bb0daeeb3cacd7cf743f?s=128

Andrew Nesbitt

August 22, 2014
Tweet

Transcript

  1. 2.
  2. 4.
  3. 5.
  4. 6.
  5. 7.
  6. 8.
  7. 10.
  8. 11.

    Advanced Mathematics Mechanical Engineering Digital Electronics Analogue Electronics Computer Science

    Control Theory Neural networking Microprocessor Design Playing with Robots Learning Robotics
  9. 12.

    Advanced Mathematics Observing Robots behind glass Learning Robotics Advanced Mathematics

    Advanced Mathematics Advanced Mathematics Advanced Mathematics Advanced Mathematics Advanced Mathematics Advanced Mathematics
  10. 14.
  11. 15.
  12. 19.
  13. 20.
  14. 22.
  15. 24.
  16. 26.
  17. 28.

    ! 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)
 }) 

  18. 32.
  19. 33.
  20. 34.
  21. 35.
  22. 36.
  23. 37.
  24. 38.
  25. 39.
  26. 40.
  27. 41.
  28. 42.
  29. 43.
  30. 44.
  31. 45.
  32. 47.
  33. 48.
  34. 53.
  35. 55.
  36. 57.
  37. 58.

    EV3

  38. 60.

    ! 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 };
  39. 61.

    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 })
 });
 });
  40. 62.
  41. 63.
  42. 68.
  43. 70.
  44. 72.
  45. 74.
  46. 75.

    require "rubyscad"! ! class MyShape! include RubyScad! ! def render()!

    difference do! union do! cube(size: [30, 30, 30])! cube(size: [60, 10, 10])! end! ! translate(v: [30, 30, 30]) do! sphere(r: 20)! end! end! end! end! ! MyShape.new.render
  47. 77.
  48. 79.
  49. 80.
  50. 82.
  51. 88.