Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var Cylon = require('cylon');
Cylon.robot({
connections: {
mqtt1: { adaptor: 'mqtt', host: 'mqtt://mqtthostname:port',username:'youruserame',password:'yourpasscode'},
firmata: { adaptor: 'firmata', port: 'COM3' }
},
devices: {
toggle: { driver: 'mqtt', topic: 'toggle', connection: 'mqtt1' },
led: { driver: 'led', pin: '13', connection: 'firmata' },
},
work: function(my) {
my.toggle.on('message', function(data) {
console.log("Message on 'toggle': " + data);
my.led.toggle();
});
every((1).second(), function() {
console.log("Toggling LED.");
my.toggle.publish('toggle');
});
}
}).start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment