Please note that @zelreedy1 has 2 topics open about the same subject. They are linked in the sense that they are about the same project, but are different questions. The other one can be found here Inaccurate IR Sensor Reading ]
I'm working on a ball and beam project where I'm using an IR sensor to find the distance of the ball along the beam and use a PID controller to control the servo motor and balance the ball in the center of the beam. However, I'm now trying to achieve another task: I'd like to place a cup anywhere under the beam, and place another sensor to detect the location of the cup. Then, based on the location of the cup, I'd like the beam to rotate appropriately to land the ball inside the cup. Here is an illustration of what I mean
I'm able to figure out the projectiles and get the correct calculations of what angle the beam needs to have to land the ball inside etc. Since the velocity of the ball would also affect the angle the beam is required to have, I'm quite unsure of how to implement an Arduino code for this one. So I'd appreciate any suggestions or resources I can use to further investigate it. Thank you!