changing states
christo27
Posts: 4
in BASIC Stamp
I have a program that when push button is pressed it will flash some lights I need to change the program so when it is pressed again it stops the flashing lights any help?
here is the code so far
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG ? IN11, CR
DO
DEBUG "WAS BUTTON PRESSED",CR
IF IN11 = 1 THEN GOTO BLUE_LIGHT_ON
LOOP
BLUE_LIGHT_ON:
DEBUG ? IN11,CR
IF IN11= 1 THEN GOSUB TRAFFIC_FLASH
TRAFFIC_FLASH:
DEBUG "BUTTON PRESSED",CR
DEBUG? IN11, CR
DEBUG "TRAFFIC FLASHING",CR
HIGH 11
HIGH 4
HIGH 2
PAUSE 700
LOW 4
LOW 2
PAUSE 700
IN11= 0
RETURN
here is the code so far
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG ? IN11, CR
DO
DEBUG "WAS BUTTON PRESSED",CR
IF IN11 = 1 THEN GOTO BLUE_LIGHT_ON
LOOP
BLUE_LIGHT_ON:
DEBUG ? IN11,CR
IF IN11= 1 THEN GOSUB TRAFFIC_FLASH
TRAFFIC_FLASH:
DEBUG "BUTTON PRESSED",CR
DEBUG? IN11, CR
DEBUG "TRAFFIC FLASHING",CR
HIGH 11
HIGH 4
HIGH 2
PAUSE 700
LOW 4
LOW 2
PAUSE 700
IN11= 0
RETURN
Comments
pin 4= led
pin 2 = led