I want to make a soccer goal counter using Arduino and some sensors. I built using an ultrasonic sensor, but it does not detect if the ball is moving too fast. Are there any other sensors I can use to detect soccer ball?

  • That may not be easy. You need to detect the ball not the goaltender, so may need to be somewhat back from the line (though this would miss technical but unlikely goals like one that slowly rolls barely over the line and stops). You need to detect a ball potentially in flight so need a grid or area not a single line. And you can't false trigger on wind so an instrumented net may be tricky. Commented Oct 2, 2016 at 17:33
  • I also felt it could be a challenging problem. I tried using ultrasonic sensors, but it does not detect if the ball is too fast. I am not sure modulated IR would work or not considering sunny and windy condition.
    – Mat_python
    Commented Oct 2, 2016 at 19:19

2 Answers 2


This is potentially well beyond the capabilities of a simple MCU like an Arduino UNO. So I think it is very important to clearly define the problem you're trying to solve.

Currently, at top national and international level, video cameras are used to detect a ball crossing the goal line. AFAICT, a lot of the complexity comes from having the goal keeper and several players on the line too. It is important that a player kicking across the goal line is not mistaken for the ball crossing the line. Also, it is important that players bodies can't block the view; a simplistic approach might not be able to see the ball if its kicked between a players legs.

This amounts to (probably) millions of sensors (one per pixel) being monitored at 100+ Hz.

So, I'll assume you are not trying to solve such a complex problem. Instead I'll assume you only want to detect a ball crossing the back edge of the goal line, without considering interference by players.

First, let's gather some numbers to describe the core problem.

A soccer ball/football is at least 68cm in circumference, so it is 68/pi = 21.6cm in diameter, or 0.216m, which is 0.108cm radius.

Then there is the goal. FIFA rules say "The distance between the posts is 7.32 m (8 yds) and the distance from the lower edge of the crossbar to the ground is 2.44 m (8 ft)"

So a question is, must the system detect the ball crossing the goal line at any place?

A goal is about 34 times wider than the diameter of the ball, and just over 11 times taller. So, if the sensors were some form of 'light beam' being broken, the 'simplest' system would need more than 11 sensors looking horizontally from one goal post to the other.

How fast might the ball travel through the posts? This says Cristiano Ronaldo was measured kicking a ball at 130km/hr. That's 36.1m/s.

So the ball is going to take 0.216/36.1 = 0.006 seconds, 6 milliseconds to pass the back edge of the goal line, ie. front edge to back edge will pass a point in 6 milliseconds. This means the sensors must all be scanned, at worst, every 6 milliseconds.

For a sound based system there are more issues.

How much of the ball is 'seen', ie. if only a small fraction of the ball is 'in view' might the returned sound be too small to register with an off-the-shelf ultrasound sensor? For example, if the angle of the reflected sound is too big, ie. from the front or back of the ball, will enough reflected sound return to the sensor to be detected?

Does the ball reflect sound well? It is a membrane at quite a low excess pressure, very different from a solid wall, so I would guess it isn't a perfect sound reflector. I haven't found anything quantifying this, but it seems reasonable to assume off-the-shelf ultrasound sensors might miss the ball under some circumstances.

So it would seem reasonable to assume that two or more sensor readings of the ball would give a significantly more reliable reading than a single sensor reading.

This equates to sampling at least every 3milliseconds. That is a maximum distance of 0.34m * 3/2millisecons (round trip) = 0.5m (approximately).

This might seem to be too much of a restriction. However, the ultrasound sensor only sends a pulse of a few cycles, so it isn't able to detect the ball for the whole of that 3 milliseconds. I haven't found a spec for the off the shelf sensors, but a plausible assumption might be each pulse lasts for about 10 cycles of 40kHz, so the pulse lasts for 0.25 milliseconds. That is the time the ball might travel, about, 1cm. So the angle of reflection would not change much. Hence trying to detect the ball more frequently will increase the quality of at least one signal.

This may explain why the ball is not always detected using ultrasound sensors in your existing approach.

Using any type of sensors to detect the ball, there is a bit of a trade-off. The ball is round, and so if the sensors are almost at the balls diameter apart, then the sensors are going to need to be scanned more quickly to detect a small part of the ball (think of this as a much smaller ball). On the other hand, if the sensors are much closer so at least one gets a longer 'view' of the ball, then one is going to see something closer to the diameter of the ball, hence see it for longer, and so they could be scanned more slowly.

This adds up to a similar outcome. Increase the number of sensors so one sees the ball for a reasonable length of time, or scan the sensors much faster to have a reasonable chance of a measurement.

A 'classic' way to detect something crossing a plane (a door way or in this case the goal mouth) is with a set of laser beams (think Mission Impossible, Entrapment, etc.).

So, consider eye-safe visible-light laser pointers? They must be eye safe, which AFAIK largely implies visible light lasers as eye-safe partly depends on the eyes 'blink response'.

At the width of a goal, the laser will have spread to several cm, but should still be straightforward to detect. With some care, it might be feasible to use mirrors to reflect a beam back towards the goal post carrying the laser, halving the number of lasers, and keeping all of the wiring on one side. I don't know how many reflections might work, but it is worth experimenting as every reflection reduces the number of lasers and sensors.

One advantage of an optical approach vs sound is the goal mouth could easily be monitored at a much higher rate than the ball could possibly pass.

To discriminate between sunlight, stadium or street lights, or other sources of light, the lasers would be modulated. 5kHz is a common figure, this is well away from mains frequency. The signal should be 'low' when the laser is off, and 'high' when the laser is on. If that isn't the case, then their is signal interference, and it isn't going to work.

With a little bit of electronics at the sensors, the signals may be purely digital, so there would be no reliance on the Arduino's slow ADC; the sensors could be scanned with digital GPIO pins, with, say, all 11 sensors being scanned at 10kHz.

You may be able to achieve a similar effect using narrow angle, high-power LEDs, lenses and tubes. A reasonable lens system should be able to focus LEDs over 7.32m of the goal mouth. However, I think eye-safe laser pointers would work with simpler optics, and the mechanics and optical systems are often harder to make robust than the electronics.

A 'raster' of eye-safe, visible-light lasers, at approximately 10cm apart, maybe with mirrors to significantly reduce the number of lasers and sensors, directed horizontally across the goal mouth, could detect a ball passing.

However, it would be confused by players across the goal line.


You should be able to detect an object as large as a soccer ball with an array of modulated IR transmitters and receivers. However you might want to avoid using IR receivers like the ones found in entertainment equipment. These have an AGC stage which will, when blocked, turn up the gain until the receiver finds a weak indirect signal. Instead, try searching using "Long-Range Presence and Proximity Sensors".

  • Great. Thanks. But, will it work in sunlight too? IR modulated Tx-Rx should be co-planar in windy condition too, which is difficult. Proximity sensors work fine for slow balls. If the ball is moving very fast, they miss sometimes. I like the idea of using modulated IR, but I am only worried about the distance. It should work fine if I place them 3 meters apart! Will it? How many modulated IR will work to create the grid?
    – Mat_python
    Commented Oct 2, 2016 at 19:17
  • Most of the sensors I have see are modulated at 38KHz. That should take care of some of the sunlight interference. But most of the applications, admittedly, are indoors. You might need to take care and place the receiver in a black tube to shield it from sunlight. Also, you probably need to mount the transmitters and detectors on the ridged part of the soccer goal frame. The municipal goals I have seen are super sturdy welded metal frames. Lenses might help but will be a bother to assemble. You might investigate COTS parts such as Garage Door Beam Interrupters.
    – st2000
    Commented Oct 2, 2016 at 19:41

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.