How do you (using a GUIDE GUI) start a while loop when a uicontrol push button (mouse button down) is pressed and then stop the loop upon the release of the push button (mouse button up)?

1 view (last 30 days)
My senior design team an I are working on building a GUI in which one of its functions is to activly control a stepper motor through an arduino (or other PLC) so that people with disabilities can perform similar work as an abled bodied person.
What we would like to do:
1) Press and Hold a pushbutton in a GUI figure -> while loop starts and provides the alternating digitalWrite high / low trigger for the arduino to provide to the stepper motor driver.
2)Release the pushbutton in the GUI figure -> the while loop terminates thus leaving the pin of the arduino in whatever write state we choose st the end of the loop.
This way the pushbuttons in the GUI will act as a vitual D-pad.
We have had minimal success using a loop and retrieving the current value of a slider and then updating the guidata each iteration. The problem with this method is that it requires the use of drawnow. Drawnow creates a slow jerk start stop action with the stepper motor that is unacceptable. In trial runs using just a function with a for or while loop that has not pause or drawnow, the communication between matlab and the arduino was fast enough for smooth movement.
If anyone can point me in the correct direction, I would greatly appreciate it. Eventually, we would like to drive this sytem over the internet, but are looking at local workstation controls at this time.
  2 Comments
Duke
Duke on 25 Nov 2013
I'm far from an expert on this but if you push a button down, there should be a call back from that, and you should be back to see if the button is in a pushed state. So couldn't you just to a while loop on the condition that the button being pushed returns true?
Michael Mihalek
Michael Mihalek on 9 Dec 2013
Thanks for the comment Duke. But so far eveything I've tried requires using drawnow so that when in the the loop the updated status of the GUI is seen. Otherwise, I end up in an endless loop condition.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 9 Dec 2013

Categories

Find more on Programming in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!