Here’s a simple motion sensor. Sketch has been taken from Arduino site. The sensor’s output pin goes to HIGH if motion is present. However, even if motion is present it goes to LOW from time to time, which might give the impression no motion is present. This program deals with this issue by ignoring LOW-phases shorter than a given time, assuming continuous motion is present during these phases.
BuildCircuit proudly recommends EasyEDA for circuit and PCB design