Need help simplifying/debuging a simple program
Jpsousa4
Posts: 2
My basic stamp and board came in the mail just a few hours ago. This is my first experience with a mircrocontroller. I've been fooling around with the button and other commands.
Right now I'm trying to get a pin to switch between high and low while the button is closed, and rest at low when open.
Problem is, it only works once. That is, the LED will blink when the button is closed, but after its opened, and closed again, the LED doesn't react.
I've checked my wiring, so its not that:
heres my code:
Any ideas on simplifying/fixing the code?
Right now I'm trying to get a pin to switch between high and low while the button is closed, and rest at low when open.
Problem is, it only works once. That is, the LED will blink when the button is closed, but after its opened, and closed again, the LED doesn't react.
I've checked my wiring, so its not that:
heres my code:
' {$STAMP BS2} ' {$PBASIC 2.5} btna VAR Byte 'define variables btnb VAR Byte work: 'main BUTTON 1,1,255,250,btna,0,noswitch 'If low, return to main. BUTTON 1,1,255,250,btnb,1,switch 'if high, go to switch. noswitch: GOTO work 'return to main switch: 'blink the LED for 250. HIGH 4 PAUSE 250 LOW 4 PAUSE 250 IF (IN1 = 0) THEN work 'if switch is let go, return to main. GOTO switch 'else, continue blinking the LED
Any ideas on simplifying/fixing the code?
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Thank you so much for helping!