Follow Slip's advice. Flip it over and, pressing hard, roll the ball in all directions over a piece of paper. 30 seconds of this or so should fix your problem.
The problem is usually a result of dust or dirt getting caught between the sensor and the ball, hence why turning it upside down would work; it would knock the dust out of the way of the sensor (usually).