Main Content

Servo Write

Set servo motor to specified angle

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

  • Servo Write block

Simulink Support Package for Arduino Hardware / Arduino Motor Carrier


The Servo Write block sets the shaft angle of a servo motor connected to an MKR Motor Carrier. To rotate the motor shaft, provide an input value ranging between 0 degrees and 180 degrees.

If you simulate a model that contains the Servo Write block without connecting the hardware, the block does nothing. For more information, see Block Produces Zeros or Does Nothing in Simulation.

Supported Hardware

You can use the Servo Write block only with MKR and Nano 33 IoT boards.



expand all

The input signal is the angle of rotation of the shaft, in degrees. The shaft angle that you specify must be any value between 0 degrees and 180 degrees. Any out-of-range values at the block input port has the same effect as the maximum or minimum input values. For example, 500 is treated as 180, and -500 is treated as 0.

The block input inherits the data type of the upstream block and internally converts the input to uint8.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32


expand all

Select the port number on the MKR Motor Carrier to which the servo motor is connected.

Version History

Introduced in R2019a