Add skynet examples

This commit is contained in:
deadprogram 2014-02-19 20:06:51 -08:00
parent e2fa83196d
commit 277643bded
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,24 @@
Cylon = require '../..'
Cylon.robot
connections: [
{ name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' },
# { name: 'skynet', adaptor: 'skynet', uuid: "742401f1-87a4-11e3-834d-670dadc0ddbf", token: "xjq9h3yzhemf5hfrme8y08fh0sm50zfr" }
{ name: 'skynet', adaptor: 'skynet', host: 'localhost', portNumber: 3000, uuid: "18676eb1-9997-11e3-8c2a-f18a07a72684", token: "vbeo289aik65hfr1lns8vst273nmi" }
]
device: { name: 'led', driver: 'led', pin: 13, connection: 'arduino' }
work: (my) ->
Logger.info "connected..."
my.connections['skynet'].on 'message', (channel, data) ->
console.log(data)
data = JSON.parse(data)
if data.red is 'on'
console.log("red on request received from skynet");
my.led.turnOn()
else if data.red is 'off'
console.log("red off request received from skynet");
my.led.turnOff()
.start()

View File

@ -0,0 +1,24 @@
var Cylon = require('../..');
Cylon.robot({
connections: [
{ name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' },
{ name: 'skynet', adaptor: 'skynet', uuid: "742401f1-87a4-11e3-834d-670dadc0ddbf", token: "xjq9h3yzhemf5hfrme8y08fh0sm50zfr" }
],
device: { name: 'led', driver: 'led', pin: 13, connection: 'arduino' },
work: function(my) {
Logger.info("connected...");
my.skynet.on('message', function(channel, data) {
Logger.info(data);
var data = JSON.parse(data);
if(data.red == 'on') {
my.led.turnOn()
}
else if(data.red == 'off') {
my.led.turnOff()
}
});
}
}).start();