Created
October 1, 2014 04:05
-
-
Save bengl/8f1c9e62c305ff68af3d to your computer and use it in GitHub Desktop.
simple webcam thing for tessel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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