Main Content

Read and Write Data

Read and write directly to Arduino® hardware

Create an Arduino object using arduino before you use read and write functions. See Connect to Arduino Hardware for more information. You can also use Arduino Explorer app to configure each pin of the Arduino to read and write data.

Note

All functions, except playTone, can be used to generate code using the MATLAB Function block. For more details, see Deploy Arduino Functions to Arduino Hardware Using MATLAB Function Block.

Functions

configurePinSet Arduino pin mode
readDigitalPinRead data from digital pin on Arduino hardware
writeDigitalPinWrite data to digital pin on Arduino hardware
writePWMVoltageGenerate PWM signal with specified voltage on digital pin
writePWMDutyCycleGenerate PWM signal with specified duty cycle on digital pin
playTonePlay tone on piezo speaker using digital pin
readVoltageRead voltage from analog pin on Arduino hardware