View Full Version : Methods for Single Button Swapping
dmaciel10123
11-05-2014, 22:15
Hi guys! So, in my last post in here I posted a swap drive that I wrote. In it I allowed for a single button to be used to swap between modes. Of course, this could cause an issue because the loop normally runs faster than a person can quickly press a button. So to account for this I put a timer in that resets only when it allows the mode to be swapped after a certain period of time. I was just wondering, are there another other, more simple ways of doing this?
Alan Anderson
11-05-2014, 22:20
Remember the state of the button the last time you checked it. If it is currently pressed but was not pressed before, then do the swap. Otherwise do nothing.
For now the question is about a button but, this leads to other questions about how to handle systems with change of state. Time to look into state machines. Two concepts that are very important to robot programming real time and state machines. We formally teach these concepts to our programming team.
I believe the attached VI is suitable for what you are looking for.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.