Skip to content

Instantly share code, notes, and snippets.

Created November 6, 2014 19:53
Show Gist options
  • Save anonymous/af5831eb0a45d3591abf to your computer and use it in GitHub Desktop.
Save anonymous/af5831eb0a45d3591abf to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Nov 6, 2014.
    24 changes: 24 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    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)
    });