-
-
Save mdobson/85dace5141d6642e7212 to your computer and use it in GitHub Desktop.
project.
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 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) |
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
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