Last active
August 29, 2015 14:18
-
-
Save virgilvox/8bd51c9b49d3af384bf8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Cylon = require('cylon'); | |
var f1v = 0; | |
Cylon.robot({ | |
connections: { | |
edison: { adaptor: 'intel-iot' }, | |
skynet: { adaptor: 'skynet', uuid: "UUID GOES HERE", token: "TOKEN GOES HERE" } | |
}, | |
devices: { | |
f1: { driver: 'analogSensor', pin: 0, lowerLimit: 0, upperLimit: 100 }, | |
led: { driver: 'led', pin: 13 } | |
}, | |
work: function(my) { | |
my.f1.on('analogRead', function(val) { | |
if((val > (f1v + 30)) || (val < (f1v - 30))){ | |
f1v = val; | |
console.log('Analog value => ', f1v); | |
my.skynet.message({ | |
"devices": "*", | |
"payload": { | |
"f1": f1v, | |
} | |
}); | |
} | |
}); | |
my.skynet.on("message", function(data) { | |
console.log(data); | |
if (data.payload.led === "on") { | |
my.led.turnOn(); | |
} else if (data.payload.led === "off") { | |
my.led.turnOff(); | |
} | |
}); | |
} | |
}).start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment