How do I detect motion?

I want to check if something is moving using distance sensors, how do I do that?