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

1 次查看(过去 30 天)
I am trying to make a GUI using App Designer that reads and graphs the voltage sensed by my Arduino Uno. When I type on the Command Window the following syntax, I get results.
a=arduino('COM5','uno')
readVoltage(a,'A0')
But when I place the same syntax in a callback function in the App Designer, the error message "Undefined function 'voltageRead' for input arguments of type 'double'." appears. Below is part of 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

回答(1 个)

Vimal Rathod
Vimal Rathod 2020-1-30
It seems like you have used voltageRead instead of readVoltage function.

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by