This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Connect to Arduino Hardware

This example shows how to connect to Arduino® hardware in MATLAB®.

Make sure the Arduino hardware is connected to the computer. If the device is unofficial, note the port and board name.

Connect to an official Arduino hardware.

a = arduino()
a = 

  arduino with properties:

                    Port: 'COM4'
                   Board: 'Uno'
           AvailablePins: {'D2-D13', 'A0-A5'}
    AvailableDigitalPins: {'D2-D13', 'A0-A5'}
        AvailablePWMPins: {'D3','D5-D6', 'D9-D11'}
     AvailableAnalogPins: {'A0-A5'}
      AvailableI2CBusIDs: [0]   
               Libraries: {'I2C','RotaryEncoder','SPI','Servo','ShiftRegister','Ultrasonic''}

Connect by specifying the port and board name.

If you are using an unofficial (clone) Arduino hardware, specify port and board name to establish connection.

a = arduino('COM4','Uno')
a = 

  arduino with properties:

                    Port: 'COM4'
                   Board: 'Uno'
           AvailablePins: {'D2-D13', 'A0-A5'}
    AvailableDigitalPins: {'D2-D13', 'A0-A5'}
        AvailablePWMPins: {'D3','D5-D6', 'D9-D11'}
     AvailableAnalogPins: {'A0-A5'}
      AvailableI2CBusIDs: [0]   
               Libraries: {'I2C','RotaryEncoder','SPI','Servo','ShiftRegister','Ultrasonic''}