Resolving

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

CONEXION ARDUINO- MATLAB

CODIGO DE PROGRAMACION
function varargout = servoslider(varargin)
% SERVOSLIDER M-file for servoslider.fig
%
SERVOSLIDER, by itself, creates a new SERVOSLIDER or raises the
existing
%
singleton*.
%
%
H = SERVOSLIDER returns the handle to a new SERVOSLIDER or the
handle to
%
the existing singleton*.
%
%
SERVOSLIDER('CALLBACK',hObject,eventData,handles,...) calls the
local
%
function named CALLBACK in SERVOSLIDER.M with the given input
arguments.
%
%
SERVOSLIDER('Property','Value',...) creates a new SERVOSLIDER or
raises the
%
existing singleton*. Starting from the left, property value pairs
are
%
applied to the GUI before servoslider_OpeningFcn gets called. An
%
unrecognized property name or invalid value makes property
application
%
stop. All inputs are passed to servoslider_OpeningFcn via
varargin.
%
%
*See GUI Options on GUIDE's Tools menu. Choose "GUI allows only
one
%
instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help servoslider
% Last Modified by GUIDE v2.5 25-Nov-2014 02:21:12
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @servoslider_OpeningFcn, ...
'gui_OutputFcn', @servoslider_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
% End initialization code - DO NOT EDIT

% --- Executes just before servoslider is made visible.


function servoslider_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject
handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% varargin
command line arguments to servoslider (see VARARGIN)
axes(handles.axes1);
background = imread('image.bmp');
axis off;
imshow(background);
delete(instrfind({'Port'},{'COM6'}))
% Choose default command line output for servoslider
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
clear all;
global a;
a = arduino('COM6'); % abro el
a.servoAttach(2); % es el pin
a.servoAttach(3); % es el pin
a.servoAttach(4); % es el pin
a.servoAttach(5); % es el pin
a.servoAttach(6); % es el pin

puerto serial
usado para conectar
usado para conectar
usado para conectar
usado para conectar
usado para conectar

el
el
el
el
el

servo
servo
servo
servo
servo

% UIWAIT makes servoslider wait for user response (see UIRESUME)


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = servoslider_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject
handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;

% --- Executes on slider movement.


function slider1_Callback(hObject, eventdata, handles)
% hObject
handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
global a ;
handles.slider1=get(hObject,'Value'); %Carga en handles.slider1 el valor
delSlider
handles.slider1=round(1*handles.slider1);
set(handles.text4,'String',handles.slider1); %Escribe el valor del Slider
en statictext
vel=handles.slider1;
a.servoWrite(2,vel);

% --- Executes during object creation, after setting all properties.


function slider1_CreateFcn(hObject, eventdata, handles)
% hObject
handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns
called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end

function text4_Callback(hObject, eventdata, handles)


% hObject
handle to text4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of text4 as text
%
str2double(get(hObject,'String')) returns contents of text4 as a
double

% --- Executes on slider movement.


function slider2_Callback(hObject, eventdata, handles)
% hObject
handle to slider2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
global a ;
handles.slider2=get(hObject,'Value'); %Carga en handles.slider1 el valor
delSlider
handles.slider2=round(1*handles.slider2);
set(handles.text5,'String',handles.slider2); %Escribe el valor del Slider
en statictext
vel2=handles.slider2;
a.servoWrite(3,vel2);
% Hints: get(hObject,'Value') returns position of slider
%
get(hObject,'Min') and get(hObject,'Max') to determine range of
slider

% --- Executes during object creation, after setting all properties.


function slider2_CreateFcn(hObject, eventdata, handles)
% hObject
handle to slider2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns
called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor',[.9 .9 .9]);
end

function text5_Callback(hObject, eventdata, handles)


% hObject
handle to text5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of text5 as text
%
str2double(get(hObject,'String')) returns contents of text5 as a
double

% --- Executes during object creation, after setting all properties.


function text5_CreateFcn(hObject, eventdata, handles)
% hObject
handle to text5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns
called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes on slider movement.


function slider3_Callback(hObject, eventdata, handles)
% hObject
handle to slider3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
global a ;
handles.slider3=get(hObject,'Value'); %Carga en handles.slider1 el valor
delSlider
handles.slider3=round(1*handles.slider3);
set(handles.text6,'String',handles.slider3); %Escribe el valor del Slider
en statictext
vel3=handles.slider3;
a.servoWrite(4,vel3);
% Hints: get(hObject,'Value') returns position of slider
%
get(hObject,'Min') and get(hObject,'Max') to determine range of
slider

% --- Executes during object creation, after setting all properties.


function slider3_CreateFcn(hObject, eventdata, handles)
% hObject
handle to slider3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns
called

% Hint: slider controls usually have a light gray background.


if isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
function text6_Callback(hObject, eventdata, handles)
% hObject
handle to t1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of t1 as text
%
str2double(get(hObject,'String')) returns contents of t1 as a
double

% --- Executes during object creation, after setting all properties.


function text6_CreateFcn(hObject, eventdata, handles)
% hObject
handle to t1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns
called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes on slider movement.


function slider4_Callback(hObject, eventdata, handles)
% hObject
handle to slider4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
global a ;
handles.slider4=get(hObject,'Value'); %Carga en handles.slider1 el valor
delSlider
handles.slider4=round(1*handles.slider4);
set(handles.text7,'String',handles.slider4); %Escribe el valor del Slider
en statictext
vel4=handles.slider4;
a.servoWrite(5,vel4);
% Hints: get(hObject,'Value') returns position of slider
%
get(hObject,'Min') and get(hObject,'Max') to determine range of
slider

% --- Executes during object creation, after setting all properties.


function slider4_CreateFcn(hObject, eventdata, handles)
% hObject
handle to slider4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB

% handles
called

empty - handles not created until after all CreateFcns

% Hint: slider controls usually have a light gray background.


if isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
function text7_Callback(hObject, eventdata, handles)
% hObject
handle to t2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of t2 as text
%
str2double(get(hObject,'String')) returns contents of t2 as a
double

% --- Executes during object creation, after setting all properties.


function text7_CreateFcn(hObject, eventdata, handles)
% hObject
handle to t2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns
called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes on slider movement.


function slider5_Callback(hObject, eventdata, handles)
% hObject
handle to slider5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
global a ;
handles.slider5=get(hObject,'Value'); %Carga en handles.slider1 el valor
delSlider
handles.slider5=round(1*handles.slider5);
set(handles.text8,'String',handles.slider5); %Escribe el valor del Slider
en statictext
vel5=handles.slider5;
a.servoWrite(6,vel5);
% Hints: get(hObject,'Value') returns position of slider
%
get(hObject,'Min') and get(hObject,'Max') to determine range of
slider

% --- Executes during object creation, after setting all properties.


function slider5_CreateFcn(hObject, eventdata, handles)
% hObject
handle to slider5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB

% handles
called

empty - handles not created until after all CreateFcns

% Hint: slider controls usually have a light gray background.


if isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end

function text8_Callback(hObject, eventdata, handles)


% hObject
handle to t3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of t3 as text
%
str2double(get(hObject,'String')) returns contents of t3 as a
double

% --- Executes during object creation, after setting all properties.


function text8_CreateFcn(hObject, eventdata, handles)
% hObject
handle to t3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
empty - handles not created until after all CreateFcns
called
% Hint: edit controls usually have a white background on Windows.
%
See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes on button press in SAL.


function SAL_Callback(hObject, eventdata, handles)
% hObject
handle to SAL (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
ans=questdlg('Desea salir del programa?','SALIR','Si','No','No');
if strcmp(ans,'No')
return;
end
clear,clc,close all
% --- Executes on button press in CENT.

DISEO EN SOLIDWORK

Control de mando

You might also like