Created
April 25, 2017 21:14
-
-
Save Codymatthieu/7a0302736ae88b61025576827be7bc72 to your computer and use it in GitHub Desktop.
blinkt/ Ipfs package
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 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