App Designer not identifying 'readVoltage'

I had made a callback for a button in App Designer that when pushed would read voltages from an arduino 'A0' pin and it was wokring. Suddenly when I tried to run the app again I was getting an error of "Undefined function 'readVoltage' for input arguments of type 'double'". I had not changed the code in between this happening but now I cannot fix it.
function ButtonPushed(app, event)
clc
global b
x1=0;
global go
go=true;
while go
tempA1 = readVoltage(b, 'A0');
tempA2 = 32+(9/5)*(tempA1*100);
x1=[x1 tempA2];
plot(app.UIAxes,x1);
drawnow
pause(1);
end
end

回答 (2 件)

Ameer Hamza
Ameer Hamza 2020 年 9 月 21 日

0 投票

You have used 'b' as a global variable. In the base workspace, you need to define it as an Arduino object
b = arduino;
If it has some other type, you will get this error

4 件のコメント

Michael Pineda
Michael Pineda 2020 年 9 月 21 日
I do have 'b' as a an Arduino object. The libaries i have on it are 'I2C' 'SPI' and 'Servo' could I be missing one?
Michael Pineda
Michael Pineda 2020 年 9 月 21 日
I can read the voltages of each pin when i type readVoltage(b,'A0') in the command window perfectly. I only get this error in AppDesigner
Ameer Hamza
Ameer Hamza 2020 年 9 月 21 日
Have you typed global b in command window?
Michael Pineda
Michael Pineda 2020 年 9 月 21 日
Yes I did and the error continues to be displayed

サインインしてコメントする。

Fazli Wadood
Fazli Wadood 2023 年 3 月 22 日

0 投票

I have use this its working.
clc
global b
b = arduino;
x1=0;
global go
go=true;
while go
tempA1 = readVoltage(b, 'A0');
tempA2 = 32+(9/5)*(tempA1*100);
x1=[x1 tempA2];
plot(app.UIAxes,x1);
drawnow
pause(1);
end

カテゴリ

ヘルプ センター および File ExchangeMATLAB Support Package for Arduino Hardware についてさらに検索

製品

リリース

R2020a

質問済み:

2020 年 9 月 21 日

回答済み:

2023 年 3 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by