function varargout = untitled(varargin)



% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @untitled_OpeningFcn, ...
                   'gui_OutputFcn',  @untitled_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 untitled is made visible.
function untitled_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 untitled (see VARARGIN)

% Choose default command line output for untitled
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes untitled wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = untitled_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;
clear all;
global x;
x = serial('COM6','BAUD', 9600); % Make sure the baud rate and COM port is
                                % same as in Arduino IDE
fopen(x);

% --- Executes on button press in turnonled.
function turnonled_Callback(hObject, eventdata, handles)

global x;
fprintf(x,1);


% --- Executes on button press in turnoffled.
function turnoffled_Callback(hObject, eventdata, handles)

global x;
fprintf(x,2);

% --- Executes on button press in phototrans.
function phototrans_Callback(hObject, eventdata, handles)

global x;
fprintf(x,3);
pause(0.5);
readData = fscanf(x);
num2str(readData);


set(handles.photoVal, 'String', readData);
set(handles.photoVal, 'ForegroundColor', [1 0 0]);

% --- Executes on button press in exit.
function exit_Callback(hObject, eventdata, handles)

delete(instrfindall);
close;
