Hardware Reference
In-Depth Information
if
(digitalRead(pir_pin)
==
true
) {
// Generate filename with timestamp
filename
=
""
;
picture.runShellCommand(
"date +%s"
);
while
(picture.running());
while
(picture.available()
>0
) {
char
c
=
picture.read();
filename
+=
c;
}
filename.trim();
filename
+=
".png"
;
// Take picture
picture.runShellCommand(
"fswebcam "
+
path
+
filename
+
" -r 1280x720"
);
while
(picture.running());
// Upload to Dropbox
picture.runShellCommand(
"python "
+
path
+
"upload_picture.py "
+
path
+
filename);
while
(picture.running());
}
}
The sketch starts by including the required libraries:
#include <Bridge.h>
#include <Process.h>
We also have to declare a process, that we are going to use to call functions on the Linux
machine of the Yun (for example the fswebcam utility we used before):
Process picture;
We are also going to build a filename for each picture the project will take, that will be
stored in a string:
String filename;