Main Content

writePosition

Write position of servo motor

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

Description

example

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

Examples

collapse all

Create servo object.

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

Rotate the motor to its maximum position.

writePosition(s,1)

Input Arguments

collapse all

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

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

Version History

Introduced in R2014b