App Designer And Arduino (Reading continuous voltage from Potentiometer )

4 次查看(过去 30 天)
Hello,
I am new to App designer. I am trying to read the voltage from Anaolog input from the Arduino uno and desplay the change of the voltage on Gauge using readVotage(), but it does not work. It read reads the first value when I first starts the app, but when I keep changing the voltage from the potentiometer, it does not update in the Gauge.
Here is the code.
function SwitchValueChanged(app, event)
value = app.Switch.Value; % using a sweitch just to controll the code and LED
voltage= readVoltage(app.a,"A0");
if value == "On"
writeDigitalPin(app.a,"D9",1);
app.Gauge.Value = voltage;
app.EditField.Value=voltage;
else
writeDigitalPin(app.a,"D9",0);
app.Gauge.Value = 0;
app.EditField.Value=0;
end
end
By the way, when I run the code in a normal Matlab scripts, it works prefect and the voltage reading updates whenever I change the value of the potentiometer.
Any help with explantion would be appriciate it.
Thank you in advance.

回答(1 个)

Roja Boran Gökhan
Roja Boran Gökhan 2021-10-13
Hello, Could you find the answer? Because i got the same problem with you but i couldn't figure it out. I hope you can help me

类别

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

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by