Ambient Amplifier for Tessel
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 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