In the following bit of code there is a delay while waiting for a button to be pressed. If any of the buttons is pressed before the delay is up then a second routine is called to make a sound.
It works as I have written it, but I have noticed that the first loop that is looking for the button presses appears to "reset" if one is pressed and starts the counting again.
Is this normal operation when used this way? I'd just like to know. I know I could re-write this bit to remove that affect, but being still green on this I'm curious as to the why behind it.
Thanks.
Bart
Code:errorcheck: for loop = 1 to 4000 ' short delay once sound program is selected getbutton = GPIO & %00110101 ' get port values and keep only ports 0,2,4,5 pause 1 if getbutton <> 0 then gosub errortone ' if a button is pressed play error tone next return ' return after delay and/or error routine errortone: ' routine to produce a tone for any errors encountered for loop = 1 to 3 pause 16 sound TRANSDUCER, [75, 5, 135, 5, 75, 2] next loop return




Bookmarks