simple motion sensor

The objective of the program is no longer clear. The variable names don't provide a clue. Your requirements have not been spelled out, that I can see.

Personally, I'm tired of playing compiler for you. You have an Arduino. Try the code on your Arduino.