servos object is used to control servo’s. Similar to
servos can be used like a list. To do something with the the servo you would use:
SETTING SERVO POSITIONS
The position of servos can range from
# R.servos[SERVO_NUMBER] = POS # set servo 1's position to 20 R.servos = 20 # set servo 4's position to -75 R.servos = -75
It is important that you use integers (whole numbers, such as
10 instead of
10.0) when specifying servo positions.
You can read the last value a servo was set to using similar code:
# get the last setting of the second servo lastSetting = R.servos
While it is possible to retrieve the last position a servo was set to, this does not guarantee that the servo is currently in that position.
HOW THE SET POSITION RELATES TO THE SERVO ANGLE
The angle of an RC servo is controlled by the width of a pulse supplied to it periodically. There is no standard for the width of this pulse and there are differences between manufacturers as to what angle the servo will turn to for a given pulse width. Our hardware outputs:
|Servo setting||Timer pulse/ms|
In some cases these values will force the servo to try and turn past its internal end-stops. You should experiment and find what the actual limit of your servos are and not drive them past that.