Doppler effect
Electromagnetic waves (or sound waves) come into contact with another object while traveling; part of the wave is absorbed or reflected. A moving ball likewise absorbs or reflects some of the incoming waves.
If the ball were moving, the reflected frequency would be different. As it gets closer, its frequency becomes faster (wavelength becomes shorter). Conversely, as you move away, the frequency slows down (the wavelength becomes longer).
This phenomenon can be used to measure the speed of a moving object.