cylon/examples/leap_arduino/leap_arduino.markdown

37 lines
892 B
Markdown
Raw Normal View History

2014-02-21 08:29:18 +08:00
# Leapmotion Arduino
First, let's import Cylon:
var Cylon = require('../..');
2014-02-21 08:29:18 +08:00
Now that we have Cylon imported, we can start defining our robot
Cylon.robot({
2014-02-21 08:29:18 +08:00
Let's define the connections and devices:
connections: {
2014-11-26 06:39:24 +08:00
leap: { adaptor: 'leapmotion' },
arduino: { adaptor: 'firmata', port: '/dev/ttyACM0' }
},
2014-11-26 06:39:24 +08:00
device: { name: 'led', driver: 'led', pin: 13, connection: 'arduino' },
2014-02-21 08:29:18 +08:00
Now that Cylon knows about the necessary hardware we're going to be using, we'll
tell it what work we want to do:
work: function(my) {
2014-11-26 06:39:24 +08:00
my.leap.on('frame', function(frame) {
if (frame.hands.length > 0) {
my.led.turnOn();
} else {
my.led.turnOff();
}
});
}
2014-02-21 08:29:18 +08:00
Now that our robot knows what work to do, and the work it will be doing that
hardware with, we can start it:
}).start();