Skip to content

Instantly share code, notes, and snippets.

@bengl
Created October 1, 2014 04:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bengl/8f1c9e62c305ff68af3d to your computer and use it in GitHub Desktop.
Save bengl/8f1c9e62c305ff68af3d to your computer and use it in GitHub Desktop.
simple webcam thing for tessel
var tessel = require('tessel');
var camera = require('camera-vc0706').use(tessel.port['A']);
var notificationLED = tessel.led[3];
camera.on('error', function(err) {
console.error(err);
});
camera.on('ready', function() {
console.log('camera is ready');
var http = require('http');
http.createServer(function (req, res) {
notificationLED.high();
camera.takePicture(function(err, image) {
if (err) {
console.log('error taking image', err);
res.writeHead(500);
} else {
notificationLED.low();
res.writeHead(200, {'Content-Type': 'image/jpeg'});
res.write(image);
console.log('done.');
}
res.end();
});
}).listen(1337, '0.0.0.0');
console.log('listening on port 1337');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment