• Raspberry Pi
  • Pir Sensor
  • Two leds
  • Webcam
  • This sound

Connect the Pir sensor and the two LEDs according to this


Then plug the webcam into the usb port. To take a real time photo you need to install fswebcam, we are using Arch Linux Arm and so run this command

#pacman -S fswebcam

Analyze the script

Basically we have two scripts: the first one written in Python that controls the sensor, the music and the two LEDs through gpio; the other one written in bash that takes photo from the webcam through fswebcam and saves them according to the shooting date.




Our script are free and open-source, you can download them here: (we suggest you to use wget)

$ wget
$ wget

Run the script

The procedure to run the script is similar in all the OS. Basically it depends on whether you are using python or python2. If you are using Arch Linux ARM and python2 run this

$ sudo python2

The script will run, take a photo through the webcam and save it in the same directory with the date and time corresponding to those of the shot. It will turn on our two LEDs and beep when the sensor detects motion! The number of movements detected will be printed on the screen. Have fun!