How to execute arduino functions using MATLAB interface

3 次查看(过去 30 天)
I need to execute commands other than IO commands while interfacing with arduino through MATLAB. In particular I need to measure correctly the current supply voltage to precisely convert the ADC values into voltage signals. The code for arduino is
long readVcc() {
long result;
// Read 1.1V reference against AVcc
ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
delay(2); // Wait for Vref to settle
ADCSRA |= _BV(ADSC); // Convert
while (bit_is_set(ADCSRA,ADSC));
result = ADCL;
result |= ADCH<<8;
result = 1126400L / result; // Back-calculate AVcc in mV
return result;
}
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println( readVcc(), DEC );
delay(1000);}
My main thrust is to somehow port the readVcc function so that I can execute it from MATLAB. Is this possible and if any guide is available for this is available, please link it. My main thrust is to execute a command like follows
a=arduino('COM5')
vcc=a.readVcc()
If any other information is further required please ask.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Support Package for Arduino Hardware 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by