Hi there,
I have a GUI set up and it has a Start pushbutton and a Stop pushbutton. Upon pushing the start, data is transmitted and received between AVR and matlab with Serial communication.
What I am trying to do is while the data is communicated and being run, if the stop button is pressed, the while operation should stop. This should be accomplished if I can just break the while loop, but the code that I've tried using 'assignin' and 'evalin' hasn't succeeded. Actually it occasionally works but sometimes doesn't work. Here is what my code :
function StartButton_Callback(hObject, eventdata, handles)flag = 0;assignin('base','flag', flag);bt = Bluetooth('JCNET-BT-7827',1);fopen(bt);while 1 %%Receiving and Display Serial Communication
flag = evalin('base', 'flag'); if flag == 1 break; endend
When the EndButton is pressed,
% --- Executes on button press in EndButton.
function EndButton_Callback(hObject, eventdata, handles)flag = 1;assignin('base','flag', flag);
Could anyone give me for advices? Thanks a lot in advance!
Best Answer