Main Content

readPosition

Read servo motor position

Description

example

position = readPosition(s) reads the position of the motor shaft and returns the value of the position in ratio to the maximum angle of the specified servomotor.

Examples

collapse all

Create servo object.

a = arduino('COM4','Uno','Libraries','Servo');
s = servo(a,'D4');

Read the position of the servo.

position = readPosition(s)
position = 0.5200

Input Arguments

collapse all

Servo object connected to Arduino® hardware specified as an object.

Output Arguments

collapse all

Position of the servo motor specified as a number representing the angle from 0 to 1 .

Version History

Introduced in R2014b