COMUNICACION SERIAL DSPIC30F3014 Y MATLAB

C:UsersCARLOSDesktoppractica dspicUART_LEDS.c
#include "p30fxxxx.h" #include "LCD.h" #include "UART.h"
#include "libpic30.h"
//Macros para la configuración de los fusibles
_FOSC(CSW_FSCM_OFF & XT_PLL4); _FWDT(WDT_OFF); _FBORPOR(PBOR_OFF & PWRT_16 & MCLR_EN);
_FGS(CODE_PROT_OFF);
#define BORRAR_HYPERTERMINAL TX_UART1_CHAR('f')
unsigned char rx; void main() {
ADPCFG = 0xFFFF;
__delay_ms(15);
//LCD_CONFIG();
INICIO_UART1(_9600);
//BORRAR_HYPERTERMINAL; //TX_UART1_MENSAJE("Hola alumnos UTPnr",18); //TX_UART1_MENSAJE("ttCuanto va el Peru
Panama?nr",29);
ADPCFG = 0XFFFF;
TRISB = 0xFF00; //Los cuatro pines menos significativos son salida
while(1);
}
void __attribute__((__interrupt__))_U1RXInterrupt(void)
{
rx = U1RXREG;
// if(rx=='s' || rx=='S')
if(rx=='A' ) { PORTBbits.RB0 = 1; __delay_ms(200);PORTBbits.RB0 = 0; __delay_ms(200);}
if(rx=='B' ) { PORTBbits.RB1 = 1; __delay_ms(200);PORTBbits.RB1 = 0; __delay_ms(200); }
// TX_UART1_MENSAJE("Va ganando Peru 2 a 1n",23);
IFS0bits.U1RXIF = 0;
}
// ***********************CONFIGURACION DEL REGISTRO UART***************************
void INICIO_UART1(unsigned char baudios)
{
U1BRG = baudios; //9600 bps, U1BRG es un registro de 16 bits U1MODE = 0; //8 bits de datos, sin paridad(STSEL=0) y 1 bit de
stop.
/*PDSEL<1:0> - Parity and data selection bits 00 – 8-bit data, no parity 01 – 8-bit data, even parity 10 – 8-bit data, odd parity 11 – 9-bit
data, no parity*/
// STSEL – STOP selection bit (STSEL=0 one STOP bit, STSEL=1 two STOP bits)
U1MODEbits.UARTEN = 1; // habilito UART dentro del registro U1MODE
U1STAbits.UTXEN = 1; // habilito la transmision dentro del registro U1STA
IPC2 = IPC2 | 0x0030; // Prioridad nivel 3 para U1RXIP
/* Los registros IECx permite habilitar las respectivas interrupciones del CPU. Una vez puesto a '1' logico el respectivo bit, la
interrupcion queda activa y es posible que un evento la dispare. Estos bits,normalmente se habilitan una sola vez en el programa, a
menos que el programador desee desactivar la interrupcion a raiz de otro evento */
IEC0bits.U1RXIE = 1; // Para habilitar la interrupcion
/* Los registros IFSx contienen las banderas de las diversas interrupciones del DSPIC30F3014. Estas banderas automaticamente se
ponen a '1' logico para indicar que una interrupcion ha ocurrido. Una vez atendida la interrupcion esta bandera debe ser puesta a '0'
logico por firmware, ya que de no hacerlo la rutina de interrupcion sera considerada no atendida por el CPU y esta se volvera a
ejecutar */
IFS0bits.U1RXIF = 0; // Para borrar la bandera o flag de interrupcion por el U1RXREG
}
void TX_UART1_CHAR(unsigned char dato)
{
U1TXREG = dato;
while(U1STAbits.TRMT == 0);
/* TRMT - Transmitir registro de desplazamiento es poco vacío (TRMT = 0 transmiten registro de desplazamiento no está vacío,
transmisión en curso, TRMT = 1 registro de desplazamiento de transmisión está vacía, la transmisión completa) */
}
void TX_UART1_MENSAJE(unsigned char *datos, unsigned char tam)
{
unsigned char i=0;
while(i<tam)
{
TX_UART1_CHAR(datos[i]);
i++;

}
}
C:UsersCARLOSDesktoppractica dspicUART.h
 este archivo incluyan como UART.h
#define _9600 64
#define _19200 32
#define _38400 15
#define _57600 10
void INICIO_UART1(unsigned char baudios);
void TX_UART1_CHAR(unsigned char dato);
void TX_UART1_MENSAJE(unsigned char *datos,unsigned char tam);
void INICIO_UART2(unsigned char baudios);
void TX_UART2_CHAR(unsigned char dato);
void TX_UART2_MENSAJE(unsigned char *datos,unsigned char tam);
EN LA FIGURA SE MUESTRA LA MANERA DE AJUNTAR ESTOS ARCHIVOS “xxx.h” y “xxx.c”
INTERFAZ GUI MATLAB PARA PROBAR LA COMUNICACIÓN SERIAL DSPIC30F3014

function varargout = LEDS(varargin)
% LEDS M-file for LEDS.fig
%
LEDS, by itself, creates a new LEDS or raises the existing
%
singleton*.
%
%
H = LEDS returns the handle to a new LEDS or the handle to
%
the existing singleton*.
%
%
LEDS('CALLBACK',hObject,eventData,handles,...) calls the local
%
function named CALLBACK in LEDS.M with the given input arguments.
%
%
LEDS('Property','Value',...) creates a new LEDS or raises the
%
existing singleton*. Starting from the left, property value pairs are
%
applied to the GUI before LEDS_OpeningFcn gets called. An
%
unrecognized property name or invalid value makes property application
%
stop. All inputs are passed to LEDS_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 LEDS
% Last Modified by GUIDE v2.5 15-Feb-2014 11:26:49
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',
mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @LEDS_OpeningFcn, ...
'gui_OutputFcn', @LEDS_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 LEDS is made visible.
function LEDS_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 LEDS (see VARARGIN)
a=imread('ALF.jpg');
imshow(a);
% Choose default command line output for LEDS
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes LEDS wait for user response (see UIRESUME)
% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = LEDS_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 button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject
handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
clear all;
s = serial('COM3');
set(s,'Baudrate',9600);
fopen(s);
fprintf(s,'%s','A');
fclose(s);
delete(s);
clear s

% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject
handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles
structure with handles and user data (see GUIDATA)
clear all;
s = serial('COM3');
set(s,'Baudrate',9600);
fopen(s);
fprintf(s,'%s','B');
fclose(s);
delete(s);
clear s
COMUNICACION SERIAL DSPIC30F3014 Y MATLAB
1 von 8

Recomendados

0.my book draft chap 1 von
0.my book draft chap 10.my book draft chap 1
0.my book draft chap 1manhduc1811
45 views6 Folien
TRAFFIC CODE MATLAB Function varargouttraffic code von
TRAFFIC CODE MATLAB Function varargouttraffic codeTRAFFIC CODE MATLAB Function varargouttraffic code
TRAFFIC CODE MATLAB Function varargouttraffic codeYograj Ghodekar
479 views14 Folien
Indirect Communications (Concurrency) von
Indirect Communications (Concurrency)Indirect Communications (Concurrency)
Indirect Communications (Concurrency)Sri Prasanna
358 views27 Folien
Mdp plus 2.1 von
Mdp plus 2.1Mdp plus 2.1
Mdp plus 2.1boedax
1.4K views8 Folien
Automatic Identification of Bug-Introducing Changes von
Automatic Identification of Bug-Introducing ChangesAutomatic Identification of Bug-Introducing Changes
Automatic Identification of Bug-Introducing ChangesThomas Zimmermann
2.2K views72 Folien
Didactum SNMP Manual von
Didactum SNMP ManualDidactum SNMP Manual
Didactum SNMP ManualDidactum
948 views12 Folien

Más contenido relacionado

Was ist angesagt?

Realisation de controlleur VGA(VHDL) von
Realisation de controlleur VGA(VHDL)Realisation de controlleur VGA(VHDL)
Realisation de controlleur VGA(VHDL)yahya ayari
5.9K views76 Folien
Anomalies in X-Ray Engine von
Anomalies in X-Ray EngineAnomalies in X-Ray Engine
Anomalies in X-Ray EnginePVS-Studio
50 views25 Folien
Simware framework hello world: A webinar von
Simware framework hello world: A webinarSimware framework hello world: A webinar
Simware framework hello world: A webinarJosé Ramón Martínez Salio
433 views17 Folien
Blood pressure set programming von
Blood pressure set programmingBlood pressure set programming
Blood pressure set programmingNoorshahida Kassim
381 views12 Folien
Rootkit on Linux X86 v2.6 von
Rootkit on Linux X86 v2.6Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6fisher.w.y
2.5K views61 Folien
Embedded JavaScript von
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScriptJens Siebert
419 views20 Folien

Was ist angesagt?(7)

Realisation de controlleur VGA(VHDL) von yahya ayari
Realisation de controlleur VGA(VHDL)Realisation de controlleur VGA(VHDL)
Realisation de controlleur VGA(VHDL)
yahya ayari5.9K views
Anomalies in X-Ray Engine von PVS-Studio
Anomalies in X-Ray EngineAnomalies in X-Ray Engine
Anomalies in X-Ray Engine
PVS-Studio50 views
Rootkit on Linux X86 v2.6 von fisher.w.y
Rootkit on Linux X86 v2.6Rootkit on Linux X86 v2.6
Rootkit on Linux X86 v2.6
fisher.w.y2.5K views
Capture and replay hardware behaviour for regression testing and bug reporting von martin-pitt
Capture and replay hardware behaviour for regression testing and bug reportingCapture and replay hardware behaviour for regression testing and bug reporting
Capture and replay hardware behaviour for regression testing and bug reporting
martin-pitt360 views

Similar a COMUNICACION SERIAL DSPIC30F3014 Y MATLAB

망고100 보드로 놀아보자 15 von
망고100 보드로 놀아보자 15망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15종인 전
411 views26 Folien
matlab.code.has.docx von
matlab.code.has.docxmatlab.code.has.docx
matlab.code.has.docxssuserfe37cb
89 views3 Folien
Antenna Physical Characetristics von
Antenna Physical CharacetristicsAntenna Physical Characetristics
Antenna Physical CharacetristicsAssignmentpedia
425 views11 Folien
Actividad #7 codigo detección de errores (yango colmenares) von
Actividad #7 codigo detección de errores (yango colmenares)Actividad #7 codigo detección de errores (yango colmenares)
Actividad #7 codigo detección de errores (yango colmenares)Yango Alexander Colmenares
406 views8 Folien
Embedded systemsproject_2020 von
Embedded systemsproject_2020Embedded systemsproject_2020
Embedded systemsproject_2020Nikos Mouzakitis
76 views27 Folien
PIC and LCD von
PIC and LCDPIC and LCD
PIC and LCDhairilfaiz86
891 views4 Folien

Similar a COMUNICACION SERIAL DSPIC30F3014 Y MATLAB(20)

망고100 보드로 놀아보자 15 von 종인 전
망고100 보드로 놀아보자 15망고100 보드로 놀아보자 15
망고100 보드로 놀아보자 15
종인 전411 views
Part II: LLVM Intermediate Representation von Wei-Ren Chen
Part II: LLVM Intermediate RepresentationPart II: LLVM Intermediate Representation
Part II: LLVM Intermediate Representation
Wei-Ren Chen868 views
PLEASE HELP!Modify the source code to implement the followingCh.pdf von forecastfashions
PLEASE HELP!Modify the source code to implement the followingCh.pdfPLEASE HELP!Modify the source code to implement the followingCh.pdf
PLEASE HELP!Modify the source code to implement the followingCh.pdf
ISCA Final Presentaiton - Compilations von HSA Foundation
ISCA Final Presentaiton -  CompilationsISCA Final Presentaiton -  Compilations
ISCA Final Presentaiton - Compilations
HSA Foundation1.4K views
Linux Serial Driver von 艾鍗科技
Linux Serial DriverLinux Serial Driver
Linux Serial Driver
艾鍗科技1.4K views
Linux mouse von sean chen
Linux mouseLinux mouse
Linux mouse
sean chen1.1K views
LAS16-501: Introduction to LLVM - Projects, Components, Integration, Internals von Linaro
LAS16-501: Introduction to LLVM - Projects, Components, Integration, InternalsLAS16-501: Introduction to LLVM - Projects, Components, Integration, Internals
LAS16-501: Introduction to LLVM - Projects, Components, Integration, Internals
Linaro1.4K views
Stability issues of user space von 晓东 杜
Stability issues of user spaceStability issues of user space
Stability issues of user space
晓东 杜325 views
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U... von Vincenzo Iozzo
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Post Exploitation Bliss: Loading Meterpreter on a Factory iPhone, Black Hat U...
Vincenzo Iozzo714 views
The Ring programming language version 1.8 book - Part 12 of 202 von Mahmoud Samir Fayed
The Ring programming language version 1.8 book - Part 12 of 202The Ring programming language version 1.8 book - Part 12 of 202
The Ring programming language version 1.8 book - Part 12 of 202
Austin c-c++-meetup-feb2018-spectre von Kim Phillips
Austin c-c++-meetup-feb2018-spectreAustin c-c++-meetup-feb2018-spectre
Austin c-c++-meetup-feb2018-spectre
Kim Phillips321 views
Data Acquisition von azhar557
Data AcquisitionData Acquisition
Data Acquisition
azhar557564 views

Más de Carlos Buitron Quispe

Programación orientada a objetos en vb 2012 von
Programación orientada a objetos en vb 2012Programación orientada a objetos en vb 2012
Programación orientada a objetos en vb 2012Carlos Buitron Quispe
279 views2 Folien
Uso del timer2 para pwm con el pic 16 f877a con el compilador hi tech von
Uso del timer2 para pwm con el pic 16 f877a con el compilador hi techUso del timer2 para pwm con el pic 16 f877a con el compilador hi tech
Uso del timer2 para pwm con el pic 16 f877a con el compilador hi techCarlos Buitron Quispe
2.2K views5 Folien
Uso del timer0 para el pic 16 f877a con el compilador hi tech von
Uso del timer0 para el pic 16 f877a con el compilador hi techUso del timer0 para el pic 16 f877a con el compilador hi tech
Uso del timer0 para el pic 16 f877a con el compilador hi techCarlos Buitron Quispe
1.1K views3 Folien
SISTEMA RECONOCIMIENTO DE OBJETOS APLICANDO PROCESAMIENTO DE IMAGENES von
SISTEMA RECONOCIMIENTO DE OBJETOS APLICANDO PROCESAMIENTO DE IMAGENESSISTEMA RECONOCIMIENTO DE OBJETOS APLICANDO PROCESAMIENTO DE IMAGENES
SISTEMA RECONOCIMIENTO DE OBJETOS APLICANDO PROCESAMIENTO DE IMAGENESCarlos Buitron Quispe
1K views20 Folien
Tutorial de programacion en c para pic16 f877a von
Tutorial de programacion en c para pic16 f877aTutorial de programacion en c para pic16 f877a
Tutorial de programacion en c para pic16 f877aCarlos Buitron Quispe
837 views5 Folien
000191 von
000191000191
000191Carlos Buitron Quispe
705 views3 Folien

Más de Carlos Buitron Quispe(6)

COMUNICACION SERIAL DSPIC30F3014 Y MATLAB

  • 1. C:UsersCARLOSDesktoppractica dspicUART_LEDS.c #include "p30fxxxx.h" #include "LCD.h" #include "UART.h" #include "libpic30.h" //Macros para la configuración de los fusibles _FOSC(CSW_FSCM_OFF & XT_PLL4); _FWDT(WDT_OFF); _FBORPOR(PBOR_OFF & PWRT_16 & MCLR_EN); _FGS(CODE_PROT_OFF); #define BORRAR_HYPERTERMINAL TX_UART1_CHAR('f') unsigned char rx; void main() { ADPCFG = 0xFFFF; __delay_ms(15); //LCD_CONFIG(); INICIO_UART1(_9600); //BORRAR_HYPERTERMINAL; //TX_UART1_MENSAJE("Hola alumnos UTPnr",18); //TX_UART1_MENSAJE("ttCuanto va el Peru Panama?nr",29); ADPCFG = 0XFFFF; TRISB = 0xFF00; //Los cuatro pines menos significativos son salida while(1); } void __attribute__((__interrupt__))_U1RXInterrupt(void) { rx = U1RXREG; // if(rx=='s' || rx=='S') if(rx=='A' ) { PORTBbits.RB0 = 1; __delay_ms(200);PORTBbits.RB0 = 0; __delay_ms(200);} if(rx=='B' ) { PORTBbits.RB1 = 1; __delay_ms(200);PORTBbits.RB1 = 0; __delay_ms(200); } // TX_UART1_MENSAJE("Va ganando Peru 2 a 1n",23); IFS0bits.U1RXIF = 0; }
  • 2. // ***********************CONFIGURACION DEL REGISTRO UART*************************** void INICIO_UART1(unsigned char baudios) { U1BRG = baudios; //9600 bps, U1BRG es un registro de 16 bits U1MODE = 0; //8 bits de datos, sin paridad(STSEL=0) y 1 bit de stop. /*PDSEL<1:0> - Parity and data selection bits 00 – 8-bit data, no parity 01 – 8-bit data, even parity 10 – 8-bit data, odd parity 11 – 9-bit data, no parity*/ // STSEL – STOP selection bit (STSEL=0 one STOP bit, STSEL=1 two STOP bits) U1MODEbits.UARTEN = 1; // habilito UART dentro del registro U1MODE U1STAbits.UTXEN = 1; // habilito la transmision dentro del registro U1STA IPC2 = IPC2 | 0x0030; // Prioridad nivel 3 para U1RXIP /* Los registros IECx permite habilitar las respectivas interrupciones del CPU. Una vez puesto a '1' logico el respectivo bit, la interrupcion queda activa y es posible que un evento la dispare. Estos bits,normalmente se habilitan una sola vez en el programa, a menos que el programador desee desactivar la interrupcion a raiz de otro evento */ IEC0bits.U1RXIE = 1; // Para habilitar la interrupcion /* Los registros IFSx contienen las banderas de las diversas interrupciones del DSPIC30F3014. Estas banderas automaticamente se ponen a '1' logico para indicar que una interrupcion ha ocurrido. Una vez atendida la interrupcion esta bandera debe ser puesta a '0' logico por firmware, ya que de no hacerlo la rutina de interrupcion sera considerada no atendida por el CPU y esta se volvera a ejecutar */ IFS0bits.U1RXIF = 0; // Para borrar la bandera o flag de interrupcion por el U1RXREG } void TX_UART1_CHAR(unsigned char dato) { U1TXREG = dato; while(U1STAbits.TRMT == 0); /* TRMT - Transmitir registro de desplazamiento es poco vacío (TRMT = 0 transmiten registro de desplazamiento no está vacío, transmisión en curso, TRMT = 1 registro de desplazamiento de transmisión está vacía, la transmisión completa) */ }
  • 3. void TX_UART1_MENSAJE(unsigned char *datos, unsigned char tam) { unsigned char i=0; while(i<tam) { TX_UART1_CHAR(datos[i]); i++; } } C:UsersCARLOSDesktoppractica dspicUART.h  este archivo incluyan como UART.h #define _9600 64 #define _19200 32 #define _38400 15 #define _57600 10 void INICIO_UART1(unsigned char baudios); void TX_UART1_CHAR(unsigned char dato); void TX_UART1_MENSAJE(unsigned char *datos,unsigned char tam); void INICIO_UART2(unsigned char baudios); void TX_UART2_CHAR(unsigned char dato); void TX_UART2_MENSAJE(unsigned char *datos,unsigned char tam);
  • 4. EN LA FIGURA SE MUESTRA LA MANERA DE AJUNTAR ESTOS ARCHIVOS “xxx.h” y “xxx.c”
  • 5. INTERFAZ GUI MATLAB PARA PROBAR LA COMUNICACIÓN SERIAL DSPIC30F3014 function varargout = LEDS(varargin) % LEDS M-file for LEDS.fig % LEDS, by itself, creates a new LEDS or raises the existing % singleton*. % % H = LEDS returns the handle to a new LEDS or the handle to % the existing singleton*. % % LEDS('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in LEDS.M with the given input arguments. % % LEDS('Property','Value',...) creates a new LEDS or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before LEDS_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to LEDS_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
  • 6. % Edit the above text to modify the response to help LEDS % Last Modified by GUIDE v2.5 15-Feb-2014 11:26:49 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @LEDS_OpeningFcn, ... 'gui_OutputFcn', @LEDS_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 LEDS is made visible. function LEDS_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 LEDS (see VARARGIN) a=imread('ALF.jpg'); imshow(a); % Choose default command line output for LEDS handles.output = hObject; % Update handles structure guidata(hObject, handles); % UIWAIT makes LEDS wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line.
  • 7. function varargout = LEDS_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 button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) clear all; s = serial('COM3'); set(s,'Baudrate',9600); fopen(s); fprintf(s,'%s','A'); fclose(s); delete(s); clear s % --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) clear all; s = serial('COM3'); set(s,'Baudrate',9600); fopen(s); fprintf(s,'%s','B'); fclose(s); delete(s); clear s