Raspberry Pi - PIR Sensor

For my next project I want to detect movements and switch on/off something (or finally the monitor). Here is the experimental setup

  • Raspberry Pi Rev2.0
  • PIR sensor (connected to GPIO 4 + 17) - I use two pins because then I can assign a rising and falling edge event handler (see the code)
  • 2x LED (connected to GPIO 24 + 25)
  • 2x 100Ohm Resistor
  • (also on the board but not yet in use: temperature sensor)

and the corresponding source code:
To start the script at boot time I use the following initd script: