Please Look At this again Add a another routine to BUTTON Command
sam_sam_sam
Posts: 2,286
Hi, EveryOne
I would like some one to help me understand other way to use the BUTTON Demo Command
'This is what i want to add to this routine while it is running
'IF laps are Less Than 20 in the (and if button is pushed then go to this Routine)
' BUTTON.BS2
' {$STAMP BS2pe}
' {$PBASIC 2.5}
Btn············ PIN···· 10
btnWrk········· VAR···· Byte
laps··········· VAR···· Byte
laps1·········· VAR···· Byte
Main:
· '
· ' The BUTTON instruction will cause the program to branch to
· ' Press unless P0 = 0
· ' This part work very well but i want to add the following bellow
· PAUSE 5
· BUTTON Btn, 10, 255, 2, btnWrk, 0,Press
· DEBUG "*", CR
· play:·······································This routine i want to run if Button is press agian·while laps are counting to·20
·· DO........................................DO
· laps = laps + 1·........................ laps = laps + 1
· TOGGLE 9·...............................TOGGLE 9
·· PAUSE 500·.............................PAUSE·200
··· DEBUG ? laps, CR·....................DEBUG ? laps, CR
· LOOP UNTIL laps = 20.................·LOOP UNTIL laps =· 30
Press:
HIGH 9
laps = 00
GOTO main
I have been some trouble while writing this post some how the hole thing got mess up to where you could not read it any more so i
re did it
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
Sam
Post Edited (sam_sam_sam) : 1/10/2007 3:55:25 AM GMT
I would like some one to help me understand other way to use the BUTTON Demo Command
'This is what i want to add to this routine while it is running
'IF laps are Less Than 20 in the (and if button is pushed then go to this Routine)
' BUTTON.BS2
' {$STAMP BS2pe}
' {$PBASIC 2.5}
Btn············ PIN···· 10
btnWrk········· VAR···· Byte
laps··········· VAR···· Byte
laps1·········· VAR···· Byte
Main:
· '
· ' The BUTTON instruction will cause the program to branch to
· ' Press unless P0 = 0
· ' This part work very well but i want to add the following bellow
· PAUSE 5
· BUTTON Btn, 10, 255, 2, btnWrk, 0,Press
· DEBUG "*", CR
· play:·······································This routine i want to run if Button is press agian·while laps are counting to·20
·· DO........................................DO
· laps = laps + 1·........................ laps = laps + 1
· TOGGLE 9·...............................TOGGLE 9
·· PAUSE 500·.............................PAUSE·200
··· DEBUG ? laps, CR·....................DEBUG ? laps, CR
· LOOP UNTIL laps = 20.................·LOOP UNTIL laps =· 30
Press:
HIGH 9
laps = 00
GOTO main
I have been some trouble while writing this post some how the hole thing got mess up to where you could not read it any more so i
re did it
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
Sam
Post Edited (sam_sam_sam) : 1/10/2007 3:55:25 AM GMT
Comments
Please look at this post again
Something happen to this post it some how got mess up to where you could not read it·any more the computer at work has a problem it
can not show the colors and Emoticons and just mess it up today we have windows 2000 pro on it
sorry about this
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
IF (LAPS<20) AND (BUTTON=PRESSED) THEN 'Replace PRESSED with 1 or 0, depending on pressed state of the button
[noparse][[/noparse]GOSUB RUNCODE]
END IF
The idea is to check both the value of the LAPS variable and the button state with the AND comparator; both must be true to execute the conditional. Check these conditions in the main loop and execute the code in a sub routine that returns to the main loop after completion.