A basic sensor for detecting balls can be made from a
photoresitor and a laser (class one of course). Aim the laser at the photoresistor. The analog input from the photoresistor should be a high value. When the laser is not shining on the photoresistor, the value should drop.