Quote Originally Posted by Robson View Post

Check4Button:
FOR Loop = 0 TO 1000 ' 1 Second
PAUSE 1
IF Button = 0 THEN Stop ' If button was released before 1 Sec = short keypress
NEXT Loop
IF Button = 1 THEN Park ' If button was hold longer than 1 Sec = long keypress
GOTO InputButton

Stop:
' Here is your code

Park:
' Here is your other code

END
[/code]

regards Rob

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