Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Actividad4 DigII
Actividad4 DigII
21 de abril – 2023
Resumen - La práctica de laboratorio se enfocó en el uso de la plataforma electrónica “Arduino” en conjunto con el
software de análisis de datos MATLAB para la comunicación de periféricos y sensores. Para llevar a cabo la
práctica, se estableció una conexión entre el Arduino y la computadora mediante un cable USB y se cargó un
programa en el Arduino utilizando el entorno de desarrollo integrado (IDE) de Arduino. Se configuró MATLAB para
leer los datos de los sensores en tiempo real y graficarlos de manera visualmente comprensible.
Abstract - The laboratory practice focused on the use of the "Arduino" electronics platform in conjunction with
MATLAB data analysis software for peripheral and sensor communication. To carry out the practice, a connection
was established between the Arduino and the computer using a USB cable and a program was loaded on the
Arduino using the Arduino integrated development environment (IDE). MATLAB was configured to read the sensor
data in real time and plot it in a visually understandable way.
DESARROLLO –
Para la practica #5, primero se discutió por el sensor a usar que fuera excelente para la lectura de datos y
para demostrar la comunicación con periféricos y un software de apoyo. Para ello se compro el sensor PIR
HC Sr501 tal como se muestra en la siguiente imagen:
Seguido a ello, se procedió a realizar el código con las funciones correspondientes para la práctica. El código tiene
como objetivo tomar las lecturas del sensor de movimiento como “1” y “0” lógicos, lo cual encenderá un led al
procesar la información Matlab y de allí se leerán los datos en una gráfica en el tiempo especificado.
Universidad Surcolombiana, Matlab y Arduino
CODIGO
clc;
clear all;
Luego se diseñó en GUIDE una interfaz interactiva y didáctica para que el usuario pueda visualizar de
mejor manera el funcionamiento del programa anterior:
function varargout = gui_sensor_led_pir(varargin)
% GUI_SENSOR_LED_PIR MATLAB code for gui_sensor_led_pir.fig
% GUI_SENSOR_LED_PIR, by itself, creates a new GUI_SENSOR_LED_PIR or raises the existing
% singleton*.
%
% H = GUI_SENSOR_LED_PIR returns the handle to a new GUI_SENSOR_LED_PIR or the handle to
% the existing singleton*.
%
% GUI_SENSOR_LED_PIR('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUI_SENSOR_LED_PIR.M with the given input arguments.
%
% GUI_SENSOR_LED_PIR('Property','Value',...) creates a new GUI_SENSOR_LED_PIR or raises
the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before gui_sensor_led_pir_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to gui_sensor_led_pir_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
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Outputs from this function are returned to the command line.
function varargout = gui_sensor_led_pir_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)
% Actualizar el gráfico
plot(handles.axes1, tiempo, valores_led, LineWidth=2);
title(handles.axes1, 'Lecturas del LED', 'fontsize', 15);
xlabel(handles.axes1, 'Tiempo (segundos)');
ylabel(handles.axes1, 'Valor (0 o 1)');
grid(handles.axes1, 'on');
ylim(handles.axes1, [0 1.5]);
drawnow;
end
Universidad Surcolombiana, Matlab y Arduino
IMPLEMENTACION –