主要内容

writePosition

R2026b

Write position of servo motor

Description

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

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

example

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.

Alternative Functionality

App

Use Arduino Explorer to interactively configure servo motors and write position to the specified servo connected to Arduino or any other supported hardware in MATLAB® and MATLAB Online™.

For a complete list of hardware supported in the installed version of MATLAB, see Supported Hardware. For more information regarding supported boards, workflows, and platforms supported on MATLAB Online, see Get Started with MATLAB Online for Arduino.

Version History

Introduced in R2014b