필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
Pinky Salvanera
Pinky Salvanera 2020년 1월 27일
답변: Vimal Rathod 2020년 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
  댓글 수: 2
Walter Roberson
Walter Roberson 2020년 1월 27일
You should never ever have a "clear all" call in a program
Walter Roberson
Walter Roberson 2020년 1월 27일
At the point you are having trouble, app.a is probably []

댓글을 달려면 로그인하십시오.

답변 (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