Tessel Ambient
The Ambient sensor can detect ambient light and sound levels.
Clap to turn on the TV (paired with infrared) or know from a webapp if the lights are on at home.
- The microphone is optimized for detecting the ambient noise level in a room or building a sound-activated device.
- The ambient light sensor and can be used for detecting fine-grain brightness in a room.
For more info visit here.
How To Connect
Cylon.robot({ connections: { tessel: { adaptor: 'tessel', port: 'A' } }, devices: { ambient: { driver: 'ambient-attx4' } }, });
How To Use
Example using a Direct Pin.
var Cylon = require('cylon'); Cylon.robot({ connections: { tessel: { adaptor: 'tessel', port: 'A' } }, devices: { ambient: { driver: 'ambient-attx4' } }, work: function(my) { my.ambient.on('error', function (err) { console.log(err) }); my.ambient.on('light', function (data) { console.log('Light stream: ' + data); }); my.ambient.on('sound', function (data) { console.log('Sound stream: ' + data); }); every((1).seconds(), function() { my.ambient.getLightLevel(function(err, data) { console.log('Current Light level: ' + data); }); my.ambient.getSoundLevel(function(err, data) { console.log('Current Sound level: ' + data); }); }); } }).start();
Commands
ambient.clearLightTrigger( callback(err, triggerVal) )
Clears trigger listener for light trigger.
ambient.clearSoundTrigger( callback(err, triggerVal) )
Clears trigger listener for sound trigger.
ambient.getLightBuffer( callback(err, data) )
Gets the last 10 light readings.
ambient.getLightLevel( callback(err, data) )
Gets a single data point of light level.
ambient.getSoundBuffer( callback(err, data) )
Gets the last 10 sound readings.
ambient.getSoundLevel( callback(err, data) )
Gets a single data point of sound level.
ambient.setLightTrigger( triggerVal, callback(err, triggerVal) )
Sets a trigger to emit a 'light-trigger' event when triggerVal is reached. triggerVal is a float between 0 and 1.0.
ambient.setSoundTrigger( triggerVal, callback(err, triggerVal) )
Sets a trigger to emit a 'sound-trigger' event when triggerVal is reached. triggerVal is a float between 0 and 1.0.
Events
'error'
Emitted upon error.
'light'
Get a stream of light data.
'light-trigger'
Emitted upon crossing light trigger threshold.
'ready'
Emitted upon first successful communication between the Tessel and the module.
'sound'
Get a stream of sound level data.
'sound-trigger'
Emitted upon crossing sound trigger threshold.