It looks like you have everything in place to do button debouncing using the
wait_for_button subroutine, but you are never calling it from your main loop. In the beginning of your script, it jumps to the
main_loop label and enters a
BEGIN. . .REPEAT infinite loop that moves your servo back and forth. However, it looks like you have the
frame subroutine set up to handle the button presses. You might try editing your
BEGIN. . .REPEAT loop to call the
frame subroutine instead of setting the servo positions directly, which might look something like this:
2000 #first position LED control
4460 #first position servo position
7000 #second position for LEDs
7616 #second position for servo
Please note that since the
frame subroutine calls
1 servo before
2 servo, I switched the order of the servo and LED positions on the stack in the main loop. This makes it so the top number on the stack (which is the last value put on the stack) going into the subroutine will be the servo position (which is the first one used in the subroutine).
If you try modifying your script and continue having problems, could you post your updated script?