Skip to content

Instantly share code, notes, and snippets.

@henricavalcante
Last active May 17, 2016 02:25
Show Gist options
  • Save henricavalcante/90adc2d70a05a086f9081e942bd5ee13 to your computer and use it in GitHub Desktop.
Save henricavalcante/90adc2d70a05a086f9081e942bd5ee13 to your computer and use it in GitHub Desktop.
Relay control over firebase
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