Clear Filters
Clear Filters

how to enter function into app designer ?

4 views (last 30 days)
tomer polsky
tomer polsky on 18 Aug 2019
Edited: Adam Danz on 18 Jan 2020
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');
obj1 = obj1(1);
% Connect to instrument object, 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 ?

Answers (1)

Adam Danz
Adam Danz on 21 Aug 2019
Edited: Adam Danz on 18 Jan 2020
"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');


Find more on Instrument Connection and Communication in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!