simple motion sensor

You're reading a value into a variable, then overwriting the value in the variable with another read.
And then doing it again.
What's the point of that?