Try something like this.
This allows your Switch test routine to control toggling the Flag bit + Switch debounce. Then do whatever you need afterwards based on the Flag bit logic state.Code:IF Switch = 0 Then Flag = ~Flag ' Invert Flag bit WHILE Switch = 0 ' Wait for button release WEND ENDIF
Note: Be sure to use a pull-up on your Switch input, and release the Switch quickly to avoid hanging in the test routine or odd results with a floating input.




Bookmarks