Skip to content

Instantly share code, notes, and snippets.

@drnugent
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drnugent/98bc4dbf0f72d6e9edf2 to your computer and use it in GitHub Desktop.
Save drnugent/98bc4dbf0f72d6e9edf2 to your computer and use it in GitHub Desktop.
PubNub/Tessel Audio Integration
var pubnub = require("pubnub").init({publish_key: "demo", subscribe_key: "demo" });
var tessel = require("tessel")
, ambient = require('ambient-attx4').use(tessel.port['A']);
var conn = function() {
console.log("Running connect function");
ambient.on('ready', function () {
ambient.setSoundTrigger(0.1);
ambient.on('sound-trigger', function(data) {
console.log("Something happened with sound: ", data);
pubnub.publish({channel: "tessel-light", message: "Sound detected!"});
// Clear it
ambient.clearSoundTrigger();
//After 1.5 seconds reset sound trigger
setTimeout(function () {
ambient.setSoundTrigger(0.1);
},1500);
});
});
}
setTimeout(conn, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment