Main Content

Standard Servo Write

Set shaft position of standard servo motor

Library

Simulink Support Package for Arduino® Hardware/Common

Description

Set the shaft position of a standard servo motor, from 0 to 180 degrees.

To rotate the servo shaft, send values from 0 to 180 to the block input.

Sending out-of-range values, such as -5 or 200, to the block input has the same effect as sending the minimum or maximum input values.

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

During simulations without the hardware, this block does nothing.

Some limitations:

  • If you use this block in models with the Serial Receive and Serial Transmit blocks, use longer sample times to avoid overruns.

  • The maximum number of Servo blocks per model is 12 for most Arduino boards except for Arduino Mega 2560, Arduino Mega ADK hardware where the maximum is 48.

  • With Arduino Uno, Nano hardware, the Arduino PWM block cannot use digital pins 9 or 10 when the model contains Servo blocks.

  • With Arduino Mega 2560, Mega ADK hardware, the Arduino PWM block cannot use digital pins 11 or 12 when the model contains more than 12 Servo blocks.

  • With Arduino Due hardware, the Arduino PWM block cannot use digital pins 9 or 10 when the model contains Servo blocks.

Parameters

Pin number

Enter the number of the digital pin.

Do not assign the same pin number for different types of blocks as this may cause resource management conflicts.

Click View pin map to open the Arduino Pin Mapping table .

To know how to assign pins or to know about the fixed pins for the blocks, see the Arduino Pin Mapping for Timer Dependent Blocks.