Skipping a whole part of code
mfavs327
Posts: 11
I am new to programming the basic stamp and i am creating a project using it.· the project has five buttons connected to five pins on the input of the bS2.· when the first button is pressed (pin 0) the letters on the other four buttons change( the other buttons are connected to pins 1, 2,3 and 4 respectively). when any other button is pressed a letter is typed using the serout command.· i have 10 groups of letters but every time i press the first button it skips a whole group.· everything else works great except for that.
here is a piece of the code:
ASDF:
· DEBUG "in ASDF loop"
PAUSE 1000
LOW OUT15
LOW OUT14
LOW OUT13
LOW OUT12
THERE:
·DEBUG "before button"
IF IN0 = 1 THEN GOTO JKL
PAUSE 1000
·DEBUG "after button"
IF IN1 = 1 THEN GOTO HERE1
IF IN2 = 1 THEN GOTO HERE2
IF IN3 = 1 THEN GOTO HERE3
IF IN4 = 1 THEN GOTO HERE4
GOTO THERE
HERE1:
· SEROUT 16, 16468, [noparse][[/noparse]A]
· PAUSE 1000
GOTO THERE
HERE2:
· SEROUT 16, 16468, [noparse][[/noparse]S]
· PAUSE 1000
GOTO THERE
HERE3:
· SEROUT 16, 16468, [noparse][[/noparse]68]
· PAUSE 1000
GOTO THERE
HERE4:
· SEROUT 16, 16468, [noparse][[/noparse]70]
· PAUSE 1000
GOTO THERE
JKL:
PAUSE 1000
LOW OUT15
LOW OUT14
LOW OUT13
HIGH OUT12
THERE1:
IF IN0 = 1 THEN GOTO QWER
IF IN1 = 1 THEN GOTO J
IF IN2 = 1 THEN GOTO K
IF IN3 = 1 THEN GOTO L
IF IN4 = 1 THEN GOTO JKLL
GOTO THERE1
J:
· SEROUT 16, 16468, [noparse][[/noparse]74]
· PAUSE 1000
GOTO THERE1
K:
· SEROUT 16, 16468, [noparse][[/noparse]75]
· PAUSE 1000
GOTO THERE1
L:
· SEROUT 16, 16468, [noparse][[/noparse]76]
· PAUSE 1000
GOTO THERE1
JKLL:
· SEROUT 16, 16468, [noparse][[/noparse]59]
· PAUSE 1000
GOTO THERE1
QWER:
In my situation every button works (the letter buttons) but when i hit the first button it totally skips the JKL group of letters to the QWER group.· which the QWER group works perfectly.· please advise.
here is a piece of the code:
ASDF:
· DEBUG "in ASDF loop"
PAUSE 1000
LOW OUT15
LOW OUT14
LOW OUT13
LOW OUT12
THERE:
·DEBUG "before button"
IF IN0 = 1 THEN GOTO JKL
PAUSE 1000
·DEBUG "after button"
IF IN1 = 1 THEN GOTO HERE1
IF IN2 = 1 THEN GOTO HERE2
IF IN3 = 1 THEN GOTO HERE3
IF IN4 = 1 THEN GOTO HERE4
GOTO THERE
HERE1:
· SEROUT 16, 16468, [noparse][[/noparse]A]
· PAUSE 1000
GOTO THERE
HERE2:
· SEROUT 16, 16468, [noparse][[/noparse]S]
· PAUSE 1000
GOTO THERE
HERE3:
· SEROUT 16, 16468, [noparse][[/noparse]68]
· PAUSE 1000
GOTO THERE
HERE4:
· SEROUT 16, 16468, [noparse][[/noparse]70]
· PAUSE 1000
GOTO THERE
JKL:
PAUSE 1000
LOW OUT15
LOW OUT14
LOW OUT13
HIGH OUT12
THERE1:
IF IN0 = 1 THEN GOTO QWER
IF IN1 = 1 THEN GOTO J
IF IN2 = 1 THEN GOTO K
IF IN3 = 1 THEN GOTO L
IF IN4 = 1 THEN GOTO JKLL
GOTO THERE1
J:
· SEROUT 16, 16468, [noparse][[/noparse]74]
· PAUSE 1000
GOTO THERE1
K:
· SEROUT 16, 16468, [noparse][[/noparse]75]
· PAUSE 1000
GOTO THERE1
L:
· SEROUT 16, 16468, [noparse][[/noparse]76]
· PAUSE 1000
GOTO THERE1
JKLL:
· SEROUT 16, 16468, [noparse][[/noparse]59]
· PAUSE 1000
GOTO THERE1
QWER:
In my situation every button works (the letter buttons) but when i hit the first button it totally skips the JKL group of letters to the QWER group.· which the QWER group works perfectly.· please advise.
Comments
Welcome to real-time programming.
IF IN0 = 1 THEN JKL
This will wait for button 0 to be released before continuing.
Do something similar at J, K, L, and JKLL and at HERE1, HERE2, HERE3, and HERE4.
There are ways to reorganize the code to simplify this and to combine like bits of code,
but this will get you started.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen