This is a project to control a model I made with the Lego WeDo robot kit. When a ball is rolled towards the goal, the goalie will move left or right to stop it. The distance sensor is used to detect in which direction the goalie needs to move. You can see a video of the goalie in action here: https://vimeo.com/132614608 You can see more photos showing how I made the model if you look inside the project. The goalie is not actually very good at stopping the ball, mainly because the response time of the distance sensor is quite slow. This is why it is placed so far in front of the goal – the further away it is the more time there is for the goalie to move once the distance sensor has been triggered. The goalie will move left or right, depending on how far the ball is from the distance sensor when it passes. The ball has to be rolled straight towards the goal (not at an angle), and slowly, if the goalie is to have any chance of getting into position to stop it in time.
This is based on an official Lego WeDo model: https://education.lego.com/en-us/lesi/support/product-support/wedo/wedo-base-set-9580/building-instructions My addition is the sensor to detect where the ball is and a block to limit how far the arm moving the goalie can rotate one way. I have also moved the arm back, so limiting how far it can rotate the other way.