Skip to content

Instantly share code, notes, and snippets.

Created November 6, 2014 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/af5831eb0a45d3591abf to your computer and use it in GitHub Desktop.
Save anonymous/af5831eb0a45d3591abf to your computer and use it in GitHub Desktop.
Ambient Amplifier for Tessel
var tessel = require('tessel');
var ambientlib = require('ambient-attx4');
var ambient = ambientlib.use(tessel.port['A']);
var rm = 40;
ambient.on('ready', function () {
// Get points of light and sound data.
var int = setInterval( function () {
ambient.getLightLevel( function(err, ldata) {
if (err) {
throw err;
clearInterval(int);
}
var l = Math.min(rm, Math.floor(ldata*10*rm)), m = rm - l;
console.log(new Array(l).join('#') + new Array(m).join('.'), l);
})
}, 200); // The readings will happen every .5 seconds unless the trigger is hit
});
ambient.on('error', function (err) {
console.log(err)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment