9.5 Arduino Servo Functions

9.5.1 @servo/delete

: delete (dev)

Free resources of a servo object.

Inputs

dev - object to free

See also: servo.

9.5.2 @servo/display

: display (dev)

Display servo object.

Inputs

dev - device to display

See also: servo.

9.5.3 @servo/readPosition

: position = readPosition (servo)

Read the position of a servo

Inputs

servo - servo object created from arduino.servo.

Outputs

position - value between 0 .. 1 for the current servo position, where 0 is the servo min position, 1 is the servo maximum position.

See also: servo, writePosition.

9.5.4 @servo/servo

: obj = servo (arduinoobj, pin)
: obj = servo (arduinoobj, pin, propertyname, propertyvalue)

Create a servo object using a specified pin on a arduino board.

Inputs

obj - servo object

arduinoobj - connected arduino object

propertyname, propertyvalue - name value pairs for properties to pass to the created servo object.

Current properties are:

minpulseduration

min PWM pulse value in seconds.

maxpulseduration

max PWM pulse value in seconds.

Outputs

obj - created servo object.

Example

 # create arduino connection
 ar = arduino();
 # create hobby servo (1 - 2 ms pulse range)
 servo = servo(ar, "d9", "minpulseduration", 1.0e-3, "maxpulseduration", 2e-3);
 # center the servo
 writePosition(servo, 0.5);
 

Properties

The servo object has the following public properties:

parent

The parent (arduino) for this device

pins

pins used by this object

minpulseduration

minpulseduration set for object

maxpulseduration

maxpulseduration set for object

See also: arduino, readPosition, writePosition.

9.5.5 @servo/subsref

: val = subsref (dev, sub)

subref for servo

See also: servo.

9.5.6 @servo/writePosition

: writePosition (servo, position)

Write the position to a servo.

Inputs

servo - servo object created from arduino.servo.

position - value between 0 .. 1 for the current servo position, where 0 is the servo min position, 1 is the servo maximum position.

See also: servo, readPosition.


Next: Arduino Shiftregister Functions, Previous: Arduino Rotary Encoder Functions, Up: Function Reference   [Contents][Index]