Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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