how to enter function into app designer ?

조회 수: 3 (최근 30일)
tomer polsky
tomer polsky 2019년 8월 18일
편집: Adam Danz 2020년 1월 18일
So I want to use UART prtocol into my project . I build the UART protocol ,but I want to use this protocol via appdesigner . So for exmaple I want to write the number In a Numeric Field box and to send this number to the UART protocol . how do I do it ?
this is my UART protocol :
%% Instrument Connection
% Find a serial port object.
obj1 = instrfind('Type', 'serial', 'Port', 'COM3', 'Tag', '');
% Create the serial port object if it does not exist
% otherwise use the object that was found.
if isempty(obj1)
obj1 = serial('COM3');
else
fclose(obj1);
obj1 = obj1(1);
end
% Connect to instrument object, obj1.
fopen(obj1);
%%% Instrument Configuration and Control\
% Communicating with instrument object, obj1.
fwrite(obj1,23 , 'uint8');
in this last line of code :
fwrite(obj1,23 , 'uint8');
I send the number that I want to send in the UART protocol . But I want to enter this number (for example 23 in this case ) via NumericEditField in the app designer . How to do it ?

답변 (1개)

Adam Danz
Adam Danz 2019년 8월 21일
편집: Adam Danz 2020년 1월 18일
"I want to write the number in a Numeric Field box and to send this number to the UART protocol"
From within your app code, these two lines will get the numeric text value and send it to fwrite(). The two lines can be placed in any callback function that responds to interaction with a GUI component. Assuming the numeric text field is named "EditField1",
value = app.EditField1.Value; % or whatever your handle is
fwrite(obj1, value, 'uint8');

카테고리

Help CenterFile Exchange에서 Instrument Connection and Communication에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by