主要内容

在 Arduino 引脚中读取和写入数据

R2026b
直接对 Arduino® 硬件进行读写

在使用读写函数之前,请使用 arduino 创建一个 Arduino 对象。有关详细信息,请参阅Connect to Arduino Hardware。

您可以使用 Arduino 资源管理器以交互方式配置 Arduino 和其他受支持硬件上的引脚,使您能够在 MATLAB® 和 MATLAB Online™ 中读取和写入数据。有关详细信息,请参阅 Configure Read and Write for GPIO Pins Using Arduino Explorer App。

有关安装版 MATLAB 中支持的硬件的完整列表,请参阅Supported Hardware。有关 MATLAB Online 支持的板、工作流和平台的详细信息,请参阅Get Started with MATLAB Online for Arduino。

注意

除 playTone 之外的所有函数都使用 MATLAB Function 模块生成代码。有关详细信息,请参阅Deploy Arduino Functions to Arduino Hardware Using MATLAB Function Block。

函数

arduinoConnection to the Arduino and Arduino-compatible ESP32 hardware
configurePinSet Arduino pin mode
readDigitalPinRead data from a specified pin on Arduino hardware
writeDigitalPinWrite data to a specified 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

主题