Slide 44
Slide 44 text
@girlie_mac
PIR Sensor > Run Camera
board.on('ready', function() {
// Create a new `motion` hardware instance.
var motion = new five.Motion(7); //a PIR is wired on pin 7 (GPIO 4)
// 'calibrated' occurs once at the beginning of a session
motion.on('calibrated', function() {console.log('calibrated');});
motion.on('motionstart', function() { // Motion detected
// Run raspistill command to take a photo with the camera module
var filename = 'photo/image_'+i+'.jpg';
var args = ['-w', '320', '-h', '240', '-o', filename, '-t', '1'];
var spawn = child_process.spawn('raspistill', args);
...
motion detected!
Take a photo!