Hardware Reference
In-Depth Information
We also declare the pin on which the PIR motion sensor is connected:
int
pir_pin
= 8
;
And the path of the SD card on the Yun:
String path
=
"/mnt/sda1/"
;
Because we need to call functions on the Linux machine of the Yun, we have to start the
Bridge:
Bridge.begin();
Then, in the loop() part of the sketch, we check if some motion was detected by the PIR
sensor:
if
(digitalRead(pir_pin)
==
true
) {
If this is the case, we build a unique filename for the picture, with the date at which the
picture was taken:
filename
=
""
;
picture.runShellCommand(
"date +%s"
);
while
(picture.running());
while
(picture.available()
>0
) {
char
c
=
picture.read();
filename
+=
c;
}
filename.trim();
filename
+=
".png"
;
We then make the first call to the Linux machine of the Yun, first to take a picture with
the fswebcam utility. Note that here, we provide an extra argument with the -r command,
which set the resolution. I used the maximum resolution of my camera, which is 720p: