Read voltage from analog pin on Arduino hardware
Read Voltage from Analog Pin
Create an Arduino object and read voltage from and analog input pin.
a = arduino; readVoltage(a,'A4')
ans = 1.0606
a — Arduino hardware connection
Arduino hardware connection
arduino, specified as an object.
pin — Analog pin number
Analog pin number on the physical hardware, specified as a character vector.
If you connect to ESP32 board, the pin number must always correspond to a digital pin. For details, see Pin-mapping for ESP32 Boards.
voltage — Voltage read from analog pin
Voltage read from an analog pin on an Arduino hardware specified as a numeric double.
Code Generation Using MATLAB Function Block
readVoltagein a MATLAB® Function block with the Simulink® Support Package for Arduino Hardware to generate code that can be deployed on Arduino Hardware.
Configure the Arduino peripherals to the appropriate mode using
readVoltagein the MATLAB Function block.