sensor detect moving

copy code and enjoy