Main Content


Write position of servo motor

Add-On Required: This feature requires the MATLAB Support Package for Raspberry Pi Hardware add-on.


writePosition(s,position) writes the specified value to the specified servo on the Raspberry Pi® hardware.

Input Arguments

collapse all

Servo object connected to an Raspberry Pi hardware specified as an object.

Position of servo motor shaft specified as a number representing the angle from 0 to 180 degrees.


collapse all

Create servo object.

mypi = raspi();
s = servo (mypi, 12);

Rotate the motor to its mid position.

writePosition(s, 45)

Extended Capabilities

Version History

Introduced in R2016b

See Also