Main Content

motorCarrier

Connection to Arduino MKR Motor Carrier or Nano Motor Carrier

Since R2020b

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

Description

This object represents a connection to an MKR Motor Carrier or a Nano Motor Carrier. To communicate with peripherals connected to the MKR Motor Carrier or the Nano Motor Carrier, create connections to the peripherals using the functions listed under Object Functions.

The motorCarrier object uses the arduino object to establish connection to these supported boards:

Creation

Description

mcObj = motorCarrier(arduinoObj) creates a connection to the MKR Motor Carrier or Nano Motor Carrier.

example

Input Arguments

expand all

Connection to the Arduino hardware, specified as an object. To create a connection to the MKR Motor Carrier, create the arduino object with the boards MKR1000, MKR1010, or MKRZero. To create a connection to the Nano Motor Carrier, create the arduino object with the Nano33IoT board.

Example: arduinoObj = arduino('COM11','Nano33IoT','Libraries','MotorCarrier') creates a connection to the Nano Motor Carrier.

Properties

expand all

This property is read-only.

I2C serial clock pin on the Arduino hardware used by the MKR Motor Carrier or Nano Motor Carrier.

Example:

>> mcObj.SCLPin
ans = 
      'A5' 

Data Types: char

This property is read-only.

I2C serial data pin on the Arduino hardware used by the MKR Motor Carrier or Nano Motor Carrier.

Example:

>> mcObj.SDAPin
ans = 
      'A4' 

Data Types: char

I2C device address that represents a hexadecimal value, specified as a double.

Example:

>> mcObj.I2CAddress

ans = 
    102

Data Types: double

Object Functions

Use these object functions to use the peripherals on the MKR Motor Carrier or Nano Motor Carrier:

servoConnection to servo motor on Arduino MKR Motor Carrier or Nano Motor Carrier
dcmotorConnection to DC Motor on Arduino MKR Motor Carrier or Nano Motor Carrier
pidMotorConnection to motors in closed-loop PID control on Arduino MKR Motor Carrier or Nano Motor Carrier
rotaryEncoderConnection to rotary encoder on Arduino MKR Motor Carrier or Nano Motor Carrier

Examples

Create a Connection to MKR Motor Carrier

Create an arduino object with the 'MotorCarrier' library.

arduinoObj = arduino('COM13','MKR1000','Libraries','MotorCarrier')
arduinoObj =   
   
    arduino with properties:

                  Port: 'COM13'
                 Board: 'MKR1000'
         AvailablePins: {'D0-D14', 'A0-A6'}
  AvailableDigitalPins: {'D0-D14', 'A0-A6'}
      AvailablePWMPins: {'D0-D8', 'D10', 'A3-A4'}
   AvailableAnalogPins: {'A0-A6'}    
    AvailableI2CBusIDs: [0]
             Libraries: {'MotorCarrier'}
Show all properties

Create a connection to the MKR Motor Carrier.

mcObj = motorCarrier(arduinoObj)
mcObj =   
   
   MotorCarrier with properties:
              SCLPin: 'D11'
              SDAPin: 'D12'    
          I2CAddress: 102 ('0x66')

Create a Connection to Nano Motor Carrier

Create an arduino object with the 'MotorCarrier' library.

arduinoObj = arduino('COM11','Nano33IoT','Libraries','MotorCarrier');
arduinoObj =   
   
    arduino with properties:

                  Port: 'COM11'
                 Board: 'Nano33IoT'
         AvailablePins: {'D0-D13', 'A0-A7'}
  AvailableDigitalPins: {'D0-D13', 'A0-A7'}
      AvailablePWMPins: {'D2-D6', 'D9-D12', 'A2-A3', 'A5'}
   AvailableAnalogPins: {'A0-A3','A6-A7'}    
    AvailableI2CBusIDs: [0]
AvailableSerialPortIDs: [1]
             Libraries: {'MotorCarrier'}
Show all properties

Create a connection to the Nano Motor Carrier.

mcObj = motorCarrier(arduinoObj);
mcObj =   
   
   MotorCarrier with properties:

              SCLPin: 'A5'
              SDAPin: 'A4'    
          I2CAddress: 102 ('0x66')

Version History

Introduced in R2020b