Main Content


Write position of servo motor connected to MKR Motor Carrier or Nano Motor Carrier



writePosition(servoObj,position) sets the servo motor position to the specified value.


collapse all

Create a connection to the Nano Motor Carrier.

arduinoObj = arduino('/dev/ttyACM0','Nano33IoT','Libraries','MotorCarrier');
mcObj = motorCarrier(arduinoObj);

Create a connection to the servo motor 1.

servoObj = servo(mcObj,1)
servoObj = 
  Servo with properties:

    MotorNumber: 1 (Servo1)

Rotate the motor shaft to 90 degrees or pi/2 radians.


Input Arguments

collapse all

Connection to the servo motor on MKR Motor Carrier or Nano Motor Carrier, specified as an object.

Position of servo motor shaft specified as a number representing the normalized angle between 0 to 1 with 1 corresponding to 180 degrees or pi radians. 0 corresponds to the minimum angle of the motor shaft, 0 degrees or 0 radians

Introduced in R2020a