executable with arduino toolbox
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Cristian Elieser Avila Rojas
el 25 de Mayo de 2018
Respondida: Rohan Kale
el 14 de Feb. de 2020
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);
0 comentarios
Respuestas (1)
Rohan Kale
el 14 de Feb. de 2020
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
0 comentarios
Ver también
Categorías
Más información sobre MATLAB Support Package for Arduino Hardware en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!