-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
44 lines (36 loc) · 1.02 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require('dotenv').config();
// PIR Sensor stuff
const gpio = require('onoff').Gpio;
const pir = new gpio(4, 'in', 'both');
const { takePhoto, startPhoto, stopPhoto } = require('./camera');
/**
* 1. Watch for motion detected ✅
* 2. When motion detected, take a picture ✅
* 3. send pics thru tfjs trained crow/dog/etc model ✅
* 4. keep taking photos while motion detected ✅
* 5. if determined it's a crow, tweet photos! ✅
*/
// Process blocking action which can halt
// your program if deleting a large directory tree
// fs.rmdirSync(`${__dirname}/photos`, { recursive: true });
// fs.mkdirSync(`${__dirname}/photos`);
// console.log('Removed old photos');
console.log('STARTING CROW CAM!!!');
pir.watch((err, value) => {
if (err) {
throw err;
}
console.log(value);
if (value === 1) {
console.log('motion DETECTED!');
startPhoto();
takePhoto();
} else if (value === 0) {
console.log('motion STOPPED!');
stopPhoto();
}
});
// Ctrl-C
process.on('SIGINT', _ => {
pir.unexport();
});