Last active
May 17, 2016 02:25
-
-
Save henricavalcante/90adc2d70a05a086f9081e942bd5ee13 to your computer and use it in GitHub Desktop.
Relay control over firebase
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
const five = require('johnny-five'); | |
const board = new five.Board(); | |
const Firebase = require('firebase'); | |
const relays = new Firebase('https://io16natal.firebaseio.com').child('relay'); | |
board.on('ready', () => { | |
const lamps = { | |
'01': new five.Relay(8), | |
'02': new five.Relay(9), | |
'03': new five.Relay(10), | |
'04': new five.Relay(11) | |
} | |
relays.on('value', (snap) => { | |
snap.forEach((lamp) => { lamps[lamp.key()][lamp.val()]() }); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment