Set shaft position of standard servo motor to angle specified in degrees
Simulink Support Package for Arduino Hardware / Common
The Standard Servo Write block sets the shaft position of the servo motor
180 degrees depending on the input value sent
to the block on the Arduino® hardware pin.
The number of Servo blocks, Standard Servo Read, Standard Servo Write, and Continous Servo Write, you can use in your Simulink model depends on the number of timers on your Arduino hardware board. Every timer on the Arduino board can support up to 12 Servo blocks.
For example, consider the Arduino Mega 2560/ADK board. The maximum number of servo
blocks that can be used per Simulink model is 48. If your Simulink model utilizes a total number of 48 Servo blocks and the board has 5 timers,
timer 5 supports the first set of 12 (1 to 12) Servo blocks. Similarly, timer 1 supports the
next set of 12 (13-24) Servo blocks, timer 3 supports the next set of 12 (25-36) Servo
blocks, and finally, timer
4 supports the last set of 12 (37-48) servo
The Servo blocks are grouped as follows:
Set 1: Servo blocks 1 to 12
Set 2: Servo blocks 13 to 24
Set 3: Servo blocks 25 to 36
Set 4: Servo blocks 37 to 48
Set 5: Servo blocks 49 to 60
This table shows how to assign timers to Servo blocks depending on the Arduino board you are using. It also provides the maximum number of Servo blocks that you can use per Simulink model.
|Arduino Board Type||Timer||Maximum Number of Servo Blocks Per Simulink Model|
|Uno, Nano 3.0||1||Set 1|
|Mega 2560/ADK||1||Set 2|
|Leonardo, Robot Control Board, Robot Motor Board, Micro||1||Set 1|
|MKR 1000, MKR Wifi 1010, MKR Zero||TC4||Set 1|
|Nano 33 IoT||TC4||Set 1|
Data— Input value that determines speed and direction of standard rotation servo motor
The value sent to the block at the input port determines the speed and direction of rotation of the standard rotation servo motor interfaced with the Arduino hardware board. For example:
-90 to the block produces the maximum rate of
rotation in one direction.
90 to the block produces the maximum rate of
rotation in the opposite direction.
0 to the block stops the servo motor.
Sending out-of-range values, such as
300, to the block has the same effect as sending the
minimum or maximum input values, respectively.
The block input port inherits the data type of the upstream block, and internally
converts it to
uint8 with an offset of
Pin number— Standard servo write pin number
9(default) | scalar
Specify the Arduino hardware board pin number to which the standard rotation servo write motor input signal is connected.
Do not assign the same pin number to multiple blocks within a Simulink model.
For more information on how to assign pins or view the pins for the Standard Servo Write block, see Pin Mapping for Arduino Timer Dependent Blocks.
View Pin Map— Open pin mapping for Arduino hardware boards
Click this button to view the pin mapping table associated with the Arduino hardware board you select.
Conflicting Pin Configurations on Arduino Timer | Continous Servo Write | Install Support for Arduino Hardware | Model Configuration Parameters for Simulink Support Package for Arduino Hardware | Pin Mapping for Arduino Timer Dependent Blocks | PWM | Standard Servo Read