Read servo position (not called)

Hi I'm new and I don't know lots of things so I have a problem :~.

I am building a measuring tool with arduino some sensors and servos.
I want to make a servo move until a sensor detects something and then stop and measure the angle of the servo.
The different read() read the last value called, how can I read the current angle of the servo?

Thanks for your help in advance.

Your code is setting the position of the servo, so you know what the angle is.

There is a lot of variability from one servo to another, so the same command will not result in the same position. If this is within you tolerance for error, then that is all you need.

If you need more accuracy:

You can calibrate your servo. In general, they will be repeatable and linear, until they start to wear out. In other words, If you record the command to move to the zero position and the command to move to 90 degrees, you can assume that the positions in between will be linear with the command (i.e. 50% of the way between 0 command and 90 command will be 45 degrees).

You can add a position sensor to the servo. A variable resistor or encoder would be easy to interface and relatively inexpensive.

Depending on the encoder you may get the absolute position in multiple digital inputs or you may get X pulses per revolution.

You can add switches at certain points in the servo travel and use them to calibrate the position. The sketch will record the command when the first switch opens and the command when the second switch closes and use linear interpolation to calculate the command / position in between.

Steve

Read the internal Pot.