Add example of Leap Motion combined with Arduino
This commit is contained in:
parent
6360ed7c09
commit
6a83019eff
|
@ -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()
|
|
@ -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();
|
Loading…
Reference in New Issue