arduino
Connection to the Arduino and Arduino-compatible ESP32 hardware
Add-On Required: This feature requires the MATLAB Support Package for Arduino Hardware add-on.
Description
An arduino
object represents a connection to Arduino® or Arduino-compatible ESP32 hardware. Use the arduino
function to connect Arduino or Arduino-compatible ESP32 hardware to MATLAB®. After you create the object, you can program your hardware and use custom
add-on libraries directly from MATLAB using the Object Functions.
Use the arduino
object to connect to an Arduino board over USB, WiFi, or
Bluetooth, by specifying the different arguments based on the connection type. For the
supported connection type for each board, see Supported Boards.
Connection Type | Type of Valid Arguments | Option for Additional Name-Value Arguments |
---|---|---|
USB |
| Yes Specify one or more Name-Value Arguments from these options:
|
Bluetooth |
| No |
WiFi |
| No |
Creation
Syntax
Description
USB
recreates the last successful
connection to the Arduino or Arduino-compatible ESP32 hardware. If there is no last successful
connection or that connection failed, it creates a connection to an official Arduino hardware connected to your host computer via USB.a
= arduino
creates a connection with additional options specified by one or more
a
= arduino(___,Name,Value
)Name,Value
pair arguments.
Bluetooth
uses the Bluetooth® address of the supported Arduino or Arduino-compatible ESP32 hardware. For the list of Bluetooth connection
type supported hardware, see Supported Boards.a
= arduino(btaddress
)
uses the name of the of the supported Arduino or Arduino-compatible ESP32 hardware Bluetooth device to create a connection to the Arduino hardware. For the list of Bluetooth connection type supported hardware,
see Supported Boards.a
= arduino(btname
)
Input Arguments
Name-Value Arguments
Properties
Object Functions
The object functions device
, shiftRegister
, rotaryEncoder
, servo
, addon
, and ultrasonic
are used to create
objects for each of their respective peripheral devices. Other functions are used to interact
with the pins on your Arduino hardware.
device | Connection to device on I2C bus on Arduino or ESP32 hardware |
device | Connection to device on SPI bus on Arduino or ESP32 hardware |
device | Connection to serial device on Arduino or ESP32 hardware |
shiftRegister | Connection to shift register on Arduino hardware |
rotaryEncoder | Connection to quadrature encoder on Arduino or ESP32 hardware |
servo | Connection to servo motor on Arduino or ESP32 hardware |
servo | Connection to servo motor on Arduino MKR Motor Carrier or Nano Motor Carrier |
addon | Connection to add-on device for Arduino hardware |
ultrasonic | Connection to ultrasonic sensor on Arduino hardware |
motorCarrier | Connection to Arduino MKR Motor Carrier or Nano Motor Carrier |
apds9960 | Connect to APDS9960 sensor on Arduino hardware using I2C bus |
canChannel | Connection to CAN channel connected to a specified device |
configurePin | Set Arduino pin mode |
readDigitalPin | Read data from a specified pin on Arduino hardware |
writeDigitalPin | Write data to a specified pin on Arduino hardware |
writePWMVoltage | Generate PWM signal with specified voltage on digital pin |
writePWMDutyCycle | Generate PWM signal with specified duty cycle on digital pin |
playTone | Play tone on piezo speaker using digital pin |
readVoltage | Read voltage from analog pin on Arduino hardware |
scanI2CBus | Scan I2C bus on Arduino hardware for device address |
motorCarrier | Connection to Arduino MKR Motor Carrier or Nano Motor Carrier |
canChannel | Connection to CAN channel connected to a specified device |
Examples
More About
Version History
Introduced in R2014b