executable with arduino toolbox

1 次查看(过去 30 天)
Good day, I'm new to matlab and I'm working on a small project with which I want to create an executable that can be installed on any pc and this recognizes me any arduino, before creating the executable does what I want, but after create the executable only works with the arduino you have connected at the time of creating the .exe and not only this, but when installing it on any other machine does not work with any arduino, the code is below:
function varargout = audio_slave(varargin)
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @audio_slave_OpeningFcn, ...
'gui_OutputFcn', @audio_slave_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
function audio_slave_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
function varargout = audio_slave_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
function edit2_Callback(hObject, eventdata, handles)
function edit2_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function pushbutton1_Callback(hObject, eventdata, handles)
a=arduino();
activar=readDigitalPin(a,'D2');
while (activar==0)
activar=readDigitalPin(a,'D2')
end
t=10;
Fs = 44100;
cla(handles.axes1);
recObj3=audiorecorder(Fs,24,1);
disp('grabando patron')
recordblocking(recObj3,t)
disp('end');
myRecording=getaudiodata(recObj3);
plot(handles.axes1,myRecording,'b');
play(recObj3);
pause (10);

回答(1 个)

Rohan Kale
Rohan Kale 2020-2-14
In my understanding you are trying to figure out which Arduino board is connected to a machine with your GUI.
The command
a = arduino()
tries to create an arduino object with the latest arduino board settings used. Instead you may consider using this command construct
a = arduino(port,board)
for creating an arduino object with different board settings.
In your callback function 'pushbutton1_Callback', you may consider creating a cell array consisting of supported boards and try to create objects in a loop in order to detect one successfully. You may want to use try and catch statments.
Please refer to the arduino documentation page for a list of supported boards

类别

Help CenterFile Exchange 中查找有关 MATLAB Support Package for Arduino Hardware 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by