Using a PIR sensor to count motion events