So I have a Ball on Beam Project and I'm quite new to the Arduino however I have managed to complete a project prior to this so I have some experience. Basically the project demands that a ball is balanced at a point on a beam and the beam has to rotate clockwise and counter clockwise to raise or lower the beam to move the ball closer to the set point. We have a feedback system that will give an analog input, using the ADC we plan on getting it close to a set resolution number. For example if the position we require translates to the resolution number of 771, then when the analogread is > 771 the motor drives clockwise and vice versa.

The problem is that for every bit of resolution it is away from the set resolution, I would like the angle to change. For example if the set point is 771 and the analog read is reading 800 then the angle will be 'x', but as it decreases towards 771 and reaches say 780, then the angle decreases because it is closer to the set point, it can be considered a method of damping I guess, instead of leaving the angle the same and letting the system overshoot and compensating with changing the motor direction, it reduces the overshoot by reducing the angle.

Unfortunately I'm no pro at this and I am a bit lost on what to do. If anyone can guide me at least on the concept of what i should be doin or what commands to look into it would be much appreciated.

Al