I recently purchased a PIR Detector HV-SR501 and here is a simple program to use it in Python with a Raspberry Pi 3.
Let's look at the wiring:
CAUTION: Verify on the PIR sensor's board that it has to be wired as displayed, the pinout on the PIR sensor is, on some models, inverted compared to the picture.
Once wired, below is a Python program that reads from the Raspberry Pi 3's GPIO ping #11 and prints every second if a movement has been detected.
import RPi.GPIO as GPIO
print time.ctime(),": no mouvement detected"
print time.ctime(),": !!!!!!!!!! mouvement detected !!!!!!!!!!"
You can change the two resistances on the other side of the PIR sensor using a screw driver to vary the delay and sensibility of the sensor.