Created
March 31, 2017 22:46
-
-
Save chrismatthieu/c14c8b547a629957ea6023ef7a3cce02 to your computer and use it in GitHub Desktop.
This file contains hidden or 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'; | |
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