As far as I know, the servos can't be positioned in terms of "degrees"; they have a range of values from 0-255 that can be assigned thusly (all examples assume a HiTechnic controller chain off of sensor port 1 of Motor Controller->Motor Controller->Servo Controller with a servo, armServo
, in slot 1 of the servo controller):
To actually move an arm a specific degree measure, you would have to break out the protractor, and through trial and error, determine what value will move the servo 5 degrees.
If we want to increment the position of the servo with each press of a button we could use a global varriable, like this:
If you want to add another servo your program would look similar to this:
#pragma config(Hubs, S1, HTMotor, HTMotor, HTServo, none)
#pragma config(Servo, srvo_S1_C3_1, armServo, tServoNormal)
#pragma config(Servo, srvo_S1_C3_2, armServo2, tServoNormal) //Note the declaration of another servo
servo[armServo] = 43;
servo[armServo2] = 56;
Please note that currently RobotC does not allow for the use of buttons 11 and 12 (or 10 and 11 depending on how you look at it); these are the buttons that would be obtained by pressing (rather hard) on the joysticks. Do not attempt to test for them because you will not get a response, or at least I did not.
Hope this helps, and as a final note, servos can't move anything that is too heavy and would thus be a poor choice to power a heavy arm; better to use a 12v motor.