Breaking a loop GUI?
1 view (last 30 days)
Reading in accelerometer data in a GUI code. I'm trying to break the loop while reading by using the following code...
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
a = getappdata(handles.text11, 'text11');
comPort = '/dev/tty.usbmodemfd121';
[accelerometer.s,serialFlag] = setupSerial(comPort);
calCo = calibrate(accelerometer.s);
while (a == 0)
if (a == 1)
[gx gy gz] = readAcc(accelerometer,calCo);
r = sqrt((gx^2)+(gy^2)+(gz^2));
My problem is that the data keeps reading even when (a == 1), which is activated from a separate pushbutton. I've already tested the outputs of both each pushbuttons and they do read 0 and 1, but when reading the data, if I press the 1 pushbutton the data will still read.