Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var tessel = require('tessel');
- var ambientlib = require('ambient-attx4');
- var camera = require('camera-vc0706').use(tessel.port['A']);
- var ambient = ambientlib.use(tessel.port['B']);
- var notificationLED1 = tessel.led[0];
- var notificationLED2 = tessel.led[1];
- console.log('App Ready');
- ambient.on('ready', function() {
- console.log('Amb Ready');
- //camera.on('ready', function () {
- //console.log('Cam Ready');
- ambient.setSoundTrigger(0.1);
- ambient.on('sound-trigger', function(data) {
- ambient.clearSoundTrigger();
- console.log("Taking picture!");
- notificationLED1.high();
- notificationLED2.high();
- camera.takePicture(function(err, image) {
- if (err) {
- console.log('error taking image', err);
- } else {
- notificationLED1.low();
- var name = 'picture-' + Math.floor(Date.now()*1000) + '.jpg';
- process.sendfile(name, image);
- console.log('Saved.');
- //After 0.5 seconds reset sound trigger
- setTimeout(function () {
- notificationLED2.low();
- ambient.setSoundTrigger(0.1);
- },1500);
- }
- });
- });
- //});
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement