[Mod edit:
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!
As you only have the ramp, and presumably only half, to gain momentum then the pivot should be up a little bit higher so you have a larger target area to place the cup.
Do you know the kinematics?
You could attach an echo location sensor to rotate with the base to figure azimuth and distance to the edge of the cup.
The height of the cup and the pivot point will have to be known by the program.
Bonus points if you can make it flick up to send the ball farther.
Arduino can measure time, so you can simply find speed from distance and time.
However, I think this project proposition seems a bit difficult, as the only way to change the speed (that is, how to accelerate or decelerate) is to change the ramp, and changing the ramp will change the throwing height.
You should also consider that the ball will hop if you change the ramp at high speed.
For example, if you detect "high speed" shortly before reaching the edge of the ramp, you think to need slow down.
But you have to hop the ramp to slow down, and the ball probably launches in a fantastic trajectory instead of slowing down.
It may not be possible to achieve it without measuring in advance many things such as the time required for acceleration at each ramp angle, the distance and height at time to launch, and the acceleration of the ramp that can tilt the ball without hopping.
But I think this has the potential to be a great project.
When the ball is over the pivot, you a) know where it is and b) you can move the motor quickly without causing the ball to jump.
If you can hold the ball over the pivot for a few seconds, I guess it's speed will be almost zero. When you detect that, you can trigger the drop, having calculated the velocity the ball will have when it leaves the beam, based on the angle of the beam, and therefore where it will land.