Shop OBEX P1 Docs P2 Docs Learn Events
changing states — Parallax Forums

changing states

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

Comments

  • pIN11 = pushbutton
    pin 4= led
    pin 2 = led
  • christo27christo27 Posts: 4
    edited 2019-03-02 18:32
    I realized a mistake I was trying to keep a led on when PB was pressed and that high 11 was keeping it lit but doing this would never cause pin 11 to go low again any help?
  • You are "falling through" into traffic_flash when it returns.
Sign In or Register to comment.