problem with change a port in arduino connection in apps design

2 ビュー (過去 30 日間)
Imam Pratama Setiady
Imam Pratama Setiady 2021 年 7 月 20 日
i have some problem, i succeed to connection arduino with matlab menu portlist in connection. i try to change hardware connection to other port and refresh an error message appears "StringClient transport object must be connected using transport CONNECT". why its happen ? thanks
this my code
function startupFcn(app)
spl = serialportlist('available');
if isempty(spl)
error('no serial ports available')
end
app.Property = serialport(spl(1),9600,"Timeout",5)
end
this the error message
function startButtonPushed(app, event)
app.ConnLamp.Color = app.GREEN_COLOR;
global val_stop val_data
val_stop = 0;
val_sample = 300;
val_voltage = 0;
val_count = 1;
while val_count <= val_sample
if val_stop == 1
break;
else
ADC_value = str2double (readline(app.Property));
val_const(val_count) = 5;
val_voltage(val_count) = ADC_value(1)*5/308;
plot(app.UIAxes,val_voltage);
app.UIAxes.XLim = [0 val_count+50];
app.UIAxes.YLim = [0 5.1];
val_time(val_count) = val_count;
val_data = [val_voltage; val_time];
app.UITable.Data =val_data;
val_count = val_count + 1;
end
end
this a refresh code
function RefreshButtonPushed(app, event)
delete(instrfind);
p = instrhwinfo('serial');
app.PortList.Items = p.AvailableSerialPorts;
end
this the pict of connection

回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by