Skip to content

Instantly share code, notes, and snippets.

@mdobson
Last active October 19, 2015 15:12
Show Gist options
  • Save mdobson/85dace5141d6642e7212 to your computer and use it in GitHub Desktop.
Save mdobson/85dace5141d6642e7212 to your computer and use it in GitHub Desktop.
project.
var zetta = require('zetta');
var Buzzer = require('zetta-buzzer-bonescript-driver');
var Microphone = require('zetta-microphone-bonescript-driver');
var app = require('./app');
zetta()
.link('http://hello-zetta.herokuapp.com/')
.use(Buzzer)
.use(Microphone)
.use(app)
.listen(1337)
module.exports = function(server) {
var buzzerQuery = server.where({type: 'buzzer'});
var microphoneQuery = server.where({type: 'microphone'});
server.where([buzzerQuery, microphoneQuery], function(buzzer, microphone){
var volumeStream = microphone.createReadStream('volume');
volumeStream.on('data', function(msg){
if(buzzer.state == 'off' && msg.data > 30) {
buzzer.call('turn-on', function(err){
if(err) {
console.log(err);
}
});
} else {
buzzer.call('turn-off', function(err){
if(err) {
console.log(err);
}
});
}
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment