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

Learning how to Tinker

Learning how to Tinker

Hardware hacking for web developers.

Presented at Hybrid Conf 2014

Andrew Nesbitt

August 22, 2014
Tweet

More Decks by Andrew Nesbitt

Other Decks in Technology

Transcript

  1. Advanced Mathematics Mechanical Engineering Digital Electronics Analogue Electronics Computer Science

    Control Theory Neural networking Microprocessor Design Playing with Robots Learning Robotics
  2. Advanced Mathematics Observing Robots behind glass Learning Robotics Advanced Mathematics

    Advanced Mathematics Advanced Mathematics Advanced Mathematics Advanced Mathematics Advanced Mathematics Advanced Mathematics
  3. ! 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)
 }) 

  4. EV3

  5. ! 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 };
  6. 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 })
 });
 });
  7. 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