Skip to content

Instantly share code, notes, and snippets.

@chrismatthieu
Created March 31, 2017 22:46
Show Gist options
  • Save chrismatthieu/c14c8b547a629957ea6023ef7a3cce02 to your computer and use it in GitHub Desktop.
Save chrismatthieu/c14c8b547a629957ea6023ef7a3cce02 to your computer and use it in GitHub Desktop.
var ipfsAPI = require('ipfs-api');
var ipfs = ipfsAPI('localhost', '5001', {protocol: 'http'});
const topic = 'general';
var five = require('johnny-five');
five.Board().on('ready', function(){
led = new five.Led(9);
console.log('Ready');
const receiveMsg = (msg) => {
console.log(msg.data.toString());
if(msg.data.toString() == "on"){
led.on();
} else {
led.off();
}
}
ipfs.pubsub.subscribe(topic, receiveMsg);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment