Skip to content

Instantly share code, notes, and snippets.

@Codymatthieu
Created April 25, 2017 21:14
Show Gist options
  • Save Codymatthieu/7a0302736ae88b61025576827be7bc72 to your computer and use it in GitHub Desktop.
Save Codymatthieu/7a0302736ae88b61025576827be7bc72 to your computer and use it in GitHub Desktop.
blinkt/ Ipfs package
var ipfsAPI = require('ipfs-api');
var ipfs = ipfsAPI('localhost', '5001', {protocol: 'http'});
const topic = 'general';
const Blinkt = require('blinktjs');
const blinkt = new Blinkt();
const receiveMsg = (msg) => {
console.log(msg.data.toString());
if(msg.data.toString() == "on") {
blinkt.setAll(0, 0, 255);
blinkt.draw();
console.log('blue');
}
else if (msg.data.toString() == "off") {
blinkt.setAll(0, 0, 0);
blinkt.draw();
console.log('off');
}
}
ipfs.pubsub.subscribe(topic, receiveMsg);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment