% --- Executes on button press in Connect.
function Connect_Callback(hObject, eventdata, handles)
% hObject handle to Connect (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user ggg (see GUIDATA)
handles.s=serial('COM3','BaudRate',9600);
handles.s.BytesAvailableFcn = {@ReadDataOverSerial,handles};
handles.s.BytesAvailableFcnCount=12;
handles.s.BytesAvailableFcnMod='byte';
fopen(handles.s);
guidata(hObject, handles);
function ReadDataOverSerial(hObject, eventdata, handles)
global a b ;
bytes=fread(handles.s,[1,handles.s.BytesAvailable]);
set(handles.datavalues,'String',char(bytes));
timer = bytes(end-5:end); %creating new speacial array
response = bytes(1:5); %creating new speacial array
timer = str2double(timer);
response = str2double(response);
a = [a timer];
b = [b response];
plot(handles.axes1,a,b);