I am new to robotics and I had a question on servo control. I see often in the Arduino examples that rather than just saying set servo to x position a for loop is used to step through each position with a delay until the final position is reached.
I know the delay can be used to slow the movement but if I wanted to go as fast as possible could I skip the for loop and just say go to x position and do a loop while to read the position, that way I know when the servo reaches the desired position and I can continue my program?
You can definitely skip the gradual adjustment of your pulses; the servo will always try to go to the most recently received position command as quickly as it can. However, you can’t (without adding your own extra sensor or tapping into the servo somehow) know when the servo gets there since it does not tell you where it is.
Ahhh, touche, I just read the servo library read() description again and it says it returns the last set position, not the position it actually is currently at. So I guess I have to just time it or take an educated guess based on the speed of the servo listed in the specs?
As I said initially, you can also add some extra sensing system of your own. In case you haven’t seen them, I have been writing some articles about servos on my blog, starting with: