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

1 visualización (últimos 30 días)
Pinky Salvanera
Pinky Salvanera el 27 de En. de 2020
Respondida: Vimal Rathod el 30 de En. de 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
  2 comentarios
Walter Roberson
Walter Roberson el 27 de En. de 2020
You should never ever have a "clear all" call in a program
Walter Roberson
Walter Roberson el 27 de En. de 2020
At the point you are having trouble, app.a is probably []

Iniciar sesión para comentar.

Respuestas (1)

Vimal Rathod
Vimal Rathod el 30 de En. de 2020
It seems like you have used voltageRead instead of readVoltage function.

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by