Quote Originally Posted by weirdjim View Post
I'm a real newbie at the PIC, but my BASIC is fairly decent. What is the reason for the GOTO InputButton command at the end of the FOR-NEXT loop? The button will be either zero (in which case you GOTO Stp) or one (in which case you GOTO Prk). How would the code ever get to that GOTO InputButton command? Or is that a belt-and-suspenders command on the off chance that the button is released during the last millisecond of the loop?

Somebody said something about switch debounce. Is there a standard debounce code snippet for pushbutton switches? A 50 millisecond delay waiting for the sucker to stop clanging around?

Jim
1. GOTO InputButton is for start at the beginning after the button was detected as pressed. Going to Loop the program
2. If the button was released before the timer ends at 1 second means -> short press of the button.
3. ELSE long press of button.
4. Insert a pause of 20ms -50ms. My best results measured with 20ms for Button debounce.
If you have a complex matrix of columns and rows with double action feature like this, your code will slow down. I also prefer to use for next loops with Pause 1, while time critical projects and Interrupt routines.
If you insert
PAUSE 2000 is it impossible to jump to the Interrupt routine, when your pause is active.

Delay2: ' Now itīs possible to interrupt during the PAUSE and jump to your Interrupt location
FOR x = 0 TO 1000
PAUSE 1
NEXT x
RETURN

I mean that are my techniques, everyone should code like he likes it.