I want to make a 4x4 set of cups which have holes in the bottom and lead into a chamber at the bottom of the base. The user will throw a ping pong ball and try to make it into one of the cups. If the ball successfully falls through the cup, it goes into the chamber. In my basic plan, I am planning to connect 16 sensors (1 for each cup) and 16 LEDs (again 1 for each cup) to a raspberry pi which will update a web server on which cup caught the ball and then light up the corresponding cup. My question is, what type of sensor would be the best to recognize whether a ping pong ball fell into a cup or not? Any suggestions would be appreciated, thanks!

  • \$\begingroup\$ Check how infrared light is blocked by your ping-pong balls. If it's a lot then put an IR photo sensor at the bottom of the cup and illuminate the array with an incandescent lamp. \$\endgroup\$
    – Dan1138
    Commented May 8, 2020 at 16:57

1 Answer 1


No need for individual sensors. Instead, make the bottom transparent; aim a camera at the cup bases. Use opencv running on the Pi to detect the objects and tally them.

For the lights, use an addressable RGB strip. You can singulate the lights physically as needed to mount them next to the the cups.

  • \$\begingroup\$ This is a really good idea, but my base will only be around 5 inches tall so I won't have the field of view necessary for my pi camera to monitor all the cups. Do you have any recommendations for individual sensors? Also, I will definitely try the addressable RGB strip! \$\endgroup\$ Commented May 8, 2020 at 1:32
  • \$\begingroup\$ Is the open end of the cups visible from the side? Then 1 camera could see them, and use position and size to determine which cup. Another option: camera facing down from above. \$\endgroup\$ Commented May 8, 2020 at 1:38
  • \$\begingroup\$ To do direct sensing, a surface reflecting LED-phototransistor pair would work for each cup. Wire them up to an I2C expander with an interrupt pin, which would fire when any of the sensors saw a ping pong ball. Dump the expander to determine which one. Example: pololu.com/product/958 \$\endgroup\$ Commented May 8, 2020 at 1:49
  • \$\begingroup\$ I would ideally like to keep the entire contraption as one box so I don't want to use any external cameras. With the surface reflecting LED, would it respond well to white ping pong balls? \$\endgroup\$ Commented May 8, 2020 at 4:31
  • \$\begingroup\$ I daresay it would. It's infrared though, you should verify it. \$\endgroup\$ Commented May 8, 2020 at 4:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.