(이 글은 Mathwork 공식 홈페이지의 글을 참조하여 보기 쉽게 작성하였습니다)
아두이노 혹은 ESP32를 MATLAB에서 활용하기 위해서는 보드 이름을 MATLAB에서 뭐라고 인식하는지, Input Argumnent에 대한 정보가 필요합니다.
아두이노, ESP32 보드에 대한 이름입니다.
아두이노/ESP32 보드 이름과 MATLAB 지원 기능
Arduino Board | Input Argument | WiFi | Bluetooth | Supported Internal Voltage (V) |
Arduino Uno | 'Uno' | No | Yes | 5.0(default), 1.1 |
Arduino Due | 'Due' | No | Yes | 3.3(default) |
Arduino Mega 2560 | 'Mega2560' | No | Yes | 5.0(default), 1.1, 2.56 |
Arduino Leonardo | 'Leonardo' | No | Yes | 5.0(default), 2.56 |
Arduino Mega ADK | 'MegaADK' | No | No | 5.0(default), 1.1, 2.56 |
Arduino Micro | 'Micro' | No | Yes | 5.0(default), 2.56 |
Arduino MKR1000 | 'MKR1000' | Yes | No | 3.3(default), 1.0, 1.65, 2.23 |
Arduino MKR WiFi1010 | 'MKR1010' | Yes | Yes | 3.3(default), 1.0, 1.65, 2.23 |
Arduino MKR Zero | 'MKRZero' | No | No | 3.3(default), 1.0, 1.65, 2.23 |
Arduino Nano 3.1 | 'Nano3' | No | Yes | 5.0(default), 1.1 |
Arduino Nano 33 IoT | 'Nano 33IoT' | Yes | Yes | 3.3(default), 1.0, 1.65, 2.23 |
Arduino Pro Mini |
|
No | No |
|
Sparkfun Digital Sandbox | DigitalSandbox | No | No | 3.3(default), 1.1 |
Arduino Nano 33 BLE | 'Nano33BLE' | No | Yes | 3.3(default) |
Arduino Nano 33 BLE SENSE | 'Nano33BLE' | No | Yes | 3.3(default) |
ESP32-DevKitV1 | 'ESP32-WROOM-DevKitV1' | Yes | No | 3.3(default) |
ESP32-DevKitC | 'ESP32-WROOM-DevKitC' | Yes | No | 3.3(default) |
함수
Device, shiftRegister, rotaryEncoder, servo, addon, ultrasonic 등은 각각의 주변 장치에 대한 객체를 생성하는 데 사용됩니다. 그 외 함수들은 아두이노 하드웨어랑 상호작용하는 데 사용됩니다.
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 digital pin on Arduino hardware |
writeDigitalPin | Write data to digital 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 |
핀 이름
각 핀에 기능을 할당해야할텐데, 핀 이름을 뭐라고 해야 할지 몰라서 헤매는 경우도 있죠.
그럴 땐 이렇게 써보세요.
a = arduino('COM1', 'ESP32-WROOM-DevKitC')
커맨드 창에 a 엔터
그러면
a =
arduino with properties:
Port: 'COM4'
Board: 'ESP32-WROOM-DevKitC'
AvailablePins: {'D0-D5', 'D12-D19', 'D21-D23', 'D25-D27', 'D32-D39'}
AvailableDigitalPins: {'D0-D5', 'D12-D19', 'D21-D23', 'D25-D27', 'D32-D39'}
AvailablePWMPins: {'D1-D5', 'D12-D19', 'D21-D23', 'D25-D27', 'D32-D33'}
AvailableAnalogPins: {'D2', 'D4', 'D12-D15', 'D25-D27', 'D32-D36', 'D39'}
AvailableI2CBusIDs: [0]
AvailableSerialPortIDs: [2]
Libraries: {'I2C', 'SPI', 'Serial'}
Show all properties
이런 식으로 사용할 수 있는 것들이 쭈르륵 뜨게 됩니다.
아래는 가장 흔하게 사용하는 ESP32-WROOM-DevkitV1 입니다. V4혹은 그 이상도 동일합니다. 참고하세요.
a=arduino('COM3','ESP32-WROOM-DevKitV1')
Port: 'COM3'
Board: 'ESP32-WROOM-DevKitV1'
AvailablePins: {'D0', 'D2', 'D4-D5', 'D12-D19', 'D21-D23', 'D25-D27', 'D32-D39'}
AvailableDigitalPins: {'D0', 'D2', 'D4-D5', 'D12-D19', 'D21-D23', 'D25-D27', 'D32-D39'}
AvailablePWMPins: {'D2', 'D4-D5', 'D12-D19', 'D21-D23', 'D25-D27', 'D32-D33'}
AvailableAnalogPins: {'D2', 'D4', 'D12-D15', 'D25-D27', 'D32-D36', 'D39'}
AvailableI2CBusIDs: [0]
AvailableSerialPortIDs: [2]
Libraries: {'I2C', 'SPI'}
AnalogReferenceMode: 'internal'
AnalogReference: 3.300(V)
BaudRate: 115200
Bluetooth, Wifi, 등 다양하게 활용할 수 있는 예시는 Mathwork 홈페이지에서 찾아볼 수 있어요.
https://kr.mathworks.com/help/supportpkg/arduinoio/ref/arduino.html
Connection to the Arduino and Arduino-compatible ESP32 hardware - MATLAB - MathWorks 한국
이 예제의 수정된 버전이 있습니다. 사용자가 편집한 내용을 반영하여 이 예제를 여시겠습니까?
kr.mathworks.com
위 링크를 참고해보세요.

'전자 | 제어 | 항공우주 > MATLAB with ESP32' 카테고리의 다른 글
[MATLAB+아두이노] MATLAB로 ESP32, 아두이노 LED On/Off 코드 (2) | 2022.09.22 |
---|---|
ESP32에 아두이노 IDE 설치하기 (윈도우, MAC, Linux) + WiFiScan (0) | 2022.09.17 |
[MATLAB+아두이노] 아두이노 하드웨어 서포트 패키지 설치하기 (esp32, uno, 라즈베리파이, STM32) (1) | 2022.09.17 |
MATLAB&Simulink 에서 C/C++ 언어 사용하기 - MinGW-w64 (0) | 2022.09.17 |
댓글