Last active
December 31, 2015 22:09
-
-
Save tmpvar/8051933 to your computer and use it in GitHub Desktop.
leap motion to servofinger experiment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var five = require("johnny-five"); | |
var ws = new (require('ws'))('ws://localhost:6437'); | |
ws.on('open', console.log.bind(console, 'connected')); | |
ws.on('error', console.log.bind(console, 'ERROR:')); | |
(new five.Board()).on("ready", function() { | |
var servo = new five.Servo(11); | |
ws.on('message', function(data) { | |
var obj = JSON.parse(data.toString()); | |
if (obj.pointables && obj.pointables.length) { | |
var fingerPos = obj.pointables[0].touchDistance; | |
servo.to((fingerPos+.5)*270); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment