Servo.read() and Servo.write() help

jeffmorris:
How do I use Servo.read() to read the angle of the servo, add or subtract the angle value, and use Servo.write() to move the servo to the new angle value? Using the Serial Monitor, I enter 10. Servo.read() is supposed to return 90. I add 10 to 90. Servo.write() is supposed to move the servo to 100 degrees. How can I fix the problem?

oldvalue = servo1.read(); 
  • or -
    servo1.read(oldvalue);
    newvalue = oldvalue + inputvalue;
    servo1.write(newvalue);

How do I use Servo.read() to read the angle of the servo,

You can't. The function name is somewhat misleading. What Servo.read returns is the last position value you sent to the servo with a Servo.write command. There is no way to 'read' what position a servo is presently at as there is no electrical feedback signal coming from the servo back to the arduino. When you send a position value to the servo you can have no idea where it's at as it moves, or indeed even when it's reached that position and stopped, that information is simply unavailable to the common man or to the arduino. :wink:

Lefty