Detect sphere passing through opening

So, I've been coding for many years, but am new to sensors and electronics. As a learning project I've decided to make a foosball game with automatic scoring count.

Basically what I need is a sensor which detects when the ball passes through the goal opening.

One way would be to lead the ball, when it is inside the goal pit, toward to a single optical (or pressure) sensor. But this gives some time lag, and also may fail if the ball bounces back out.

So ideally I would like it to detect exactly when something passes through the opening, perhaps also say something about its size.

Could this be done with a relatively simple (i.e. not too expensive) sensor set up? Would I need some kind of array, or can it be done with one or two sensors?

Any pointers on this is much appreciated :)

A photogate or optointerruptor will work.

Basically you have an LED on one side of the opening and a photodiode or phototransistor on the other side. Lots of DIY versions on the web.

Thanks jremington!

It looks like I'll have to build my own photogate. The ones already available does not cover a big enough area.

After a bit of pondering, this is what I've come up with:


By alternating which led is turned on rapidly, I can triangulate the position of any object inside the goal area based on the position of the shadows from each led:



With a known position I can also estimate the size of the object passing based on the size of the shadows.

A few questions remain though:

Will the arduino be fast enough to detect a ball passing through in a few milliseconds? Does the IR leds radiate in a wide enough field to light up the entire sensor array?

Any thoughts?

1) The Arduino is certainly fast enough. 2) No. The data sheet for the LED will state the emission pattern.

Thanks again! Given that speed is not a problem and limited emission field I've come up with a modified approach:


Cycling through all the emitters gives an overdetermined linear system from the shadows. A more accurate position estimation should then be achievable, or what do you think?

This is an interesting idea, and in principle should work, but why would the ball not run into the emitters or detectors?

I don’t quite understand the drawing. Are we looking end on to the opening?

Yes, the sensor array is parallel to the plane formed by the opening. Here is a model:

(Its not to scale, just to show the layout.)

Since there are multiple emitters i think this would compensate for aliasing due to the low number of sensors.

Nice drawing. Cool! Let us know how it works.

With that many LEDs and photodiodes, you will probably need direct port manipulation to get the readout speed you need, rather than analogRead() (@100 us per conversion) or digitalRead() and digitalWrite().