Info

This question is closed. Reopen it to edit or answer.

Undefined function 'voltageRead' for input arguments of type 'double'.

1 view (last 30 days)
I am doing a GUI using App Designer and I am trying to read the voltage at analog pin A0 of my Arduino Uno. When I run
a = arduino('COM5','uno')
readVoltage(a, 'A0')
in the command window, I get correct results. But when the same syntax is in the code of App Designer, I get the error message "Undefined function 'voltageRead' for input arguments of type 'double'." Below is my code in the App Designer:
properties (Access = private)
stop;
done=0;
a;
h;
s;
SetPoint;
luxvolt;
end
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
clear all;
app.a = arduino('COM5','uno');
end
% Button pushed function: StartButton
function StartButtonPushed(app, event)
app.stop = false;
app.h = animatedline(app.UIAxes);
startTime = datetime('now');
axis = gca;
axis.YGrid ='on';
axis.YLim = [0 5];
while ~app.stop
app.luxvolt = voltageRead(app.a, 'A4');
%luxactual = (luxvolt - 1.4565) .* (2300 - 0) ./ (0.3519 - 1.4565) + 0;
t = datetime('now') - startTime;
addpoints(app.h,datenum(t),app.luxvolt);
drawnow
app.stop = app.done;
end
app.VoltageEditField.Value = readVoltage(app.a,'A0');

Answers (0)

Community Treasure Hunt

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

Start Hunting!