first implementation of motion monitor and relay controller on port D
complete motion monitor