This project uses IR sensors to detect when a ball is near then triggers a relay switch to the external power source letting current through the wire which pulls the ball away from the sensor and to the next magnet. No programming at all.