Add example of Leap Motion combined with Arduino

This commit is contained in:
deadprogram 2014-02-03 13:40:50 -08:00
parent 6360ed7c09
commit 6a83019eff
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,18 @@
Cylon = require '../..'
Cylon.robot
connections: [
{ name: 'leapmotion', adaptor: 'leapmotion', port: '127.0.0.1:6437' },
{ name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' }
]
devices: [
{ name: 'leapmotion', driver: 'leapmotion', connection: 'leapmotion' },
{ name: 'led', driver: 'led', pin: 13, connection: 'arduino' }
]
work: (my) ->
my.leapmotion.on 'frame', (frame) ->
if (frame.hands.length > 0) then my.led.turnOn() else my.led.turnOff()
.start()

View File

@ -0,0 +1,19 @@
var Cylon = require('../..');
Cylon.robot({
connections: [{ name: 'leapmotion', adaptor: 'leapmotion', port: '127.0.0.1:6437' },
{ name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' }],
devices: [{ name: 'leapmotion', driver: 'leapmotion', connection: 'leapmotion' },
{ name: 'led', driver: 'led', pin: 13, connection: 'arduino' }],
work: function(my) {
my.leapmotion.on('frame', function(frame) {
if (frame.hands.length > 0) {
my.led.turnOn();
} else {
my.led.turnOff();
}
});
}
}).start();