Getting leapmotion to talk to arduino.
Top level: Leapmotion makes data available via websockets on ws://127.0.0.1:6437
. Node.js can parse this. There is also a Node.js library for talking to Arduino called Johnny-five. You need something called StandardFirmata which standardises commands sent between the Arduino and a host computer, which Johnny-five speaks.
Note: the serialport
library only works with node 0.12.x
- Install nodejs
- Run
npm install
- Enable websockets on Leapmotion:
- Run
node leap.js
- Sit-back and enjoy the raw JSON feed! Example frame in
leap.json
- Flash the Arduino with StandardFirmata:
- Run
node arduino.js
- Run
node leap-arduino.js
(ref @xavier_seignard) - Placing one or more hands above leap will switch built-in LED on pin 13 on, otherwise off.
- Run
node leap-gestures.js
- You should see console output for a Screen Tap, Key Tap, Circle and Swipe.
- Run
node leap-range.js
- Move both hands around for a while in all directions
- Stop program when you stop seeing changes. The final values are the min and max ranges (in mm) of your current setup.
- Wire up a servo to pin 9.
- Run
node servo.js
. - Tweak ranges in code if need (servo and leap). Here is a demo video:
Tested using 6 degrees of freedom robot arm from: http://www.lynxmotion.com/c-130-al5d.aspx
- Open
six-servos.js
and adjust parameters - Run
node six-servos.js