MATLAB Answers

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

2 views (last 30 days)
Pinky Salvanera
Pinky Salvanera on 27 Jan 2020
Answered: Vimal Rathod on 30 Jan 2020
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

Answers (1)

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

  0 Comments

Sign in to comment.