writePosition

Write position of servo motor

Syntax

writePosition(s,position)

Description

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.

Examples

collapse all

Create servo object.

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

Rotate the motor to its mid position.

writePosition(s, 45)

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

See Also

|

Introduced in R2016b