how to hold the line until button is press
Hi there,
Im using BS2pe. What i want is the program will loop on the main program, when "enter" is pressed, it will compare the AD and the refvoltage. It will either give a pass or fail. Then it will wait for another time for button press only the program will continue. Im having a problem on the button part. The problem is my program will stuck at "Pass!! Enter to continue". And i have to press few times on the button only the program will back to the subprogram i want.
Here is my code. Thank you.
Main:
IF (IN11 = 1) THEN
IF (AD < refVoltage + (tolNumber/100) OR AD > refVoltage - (tolNumber/100)) THEN ' this line will compare the data.
HIGH LEDGreen
SEROUT RX,BAUD, ["Pass!! Enter to", CR, "continue."]
'PAUSE 10
DO WHILE IN11=0:
'IF (IN11 = 1) THEN
LOW LEDGREEN
GOTO main
'ENDIF
LOOP
ELSE
HIGH LEDRED
SEROUT RX,BAUD, ["FAIL!! Enter to", CR, "continue."]
'PAUSE 10
'DO
'IF (IN11 = 1) THEN
LOW LEDRED
GOTO main
'ENDIF
'LOOP
ENDIF
ELSE
oddSign = 1
GOSUB convert
GOSUB calc_volts
GOSUB display
PAUSE 500
GOTO main
ENDIF
Im using BS2pe. What i want is the program will loop on the main program, when "enter" is pressed, it will compare the AD and the refvoltage. It will either give a pass or fail. Then it will wait for another time for button press only the program will continue. Im having a problem on the button part. The problem is my program will stuck at "Pass!! Enter to continue". And i have to press few times on the button only the program will back to the subprogram i want.
Here is my code. Thank you.
Main:
IF (IN11 = 1) THEN
IF (AD < refVoltage + (tolNumber/100) OR AD > refVoltage - (tolNumber/100)) THEN ' this line will compare the data.
HIGH LEDGreen
SEROUT RX,BAUD, ["Pass!! Enter to", CR, "continue."]
'PAUSE 10
DO WHILE IN11=0:
'IF (IN11 = 1) THEN
LOW LEDGREEN
GOTO main
'ENDIF
LOOP
ELSE
HIGH LEDRED
SEROUT RX,BAUD, ["FAIL!! Enter to", CR, "continue."]
'PAUSE 10
'DO
'IF (IN11 = 1) THEN
LOW LEDRED
GOTO main
'ENDIF
'LOOP
ENDIF
ELSE
oddSign = 1
GOSUB convert
GOSUB calc_volts
GOSUB display
PAUSE 500
GOTO main
ENDIF

Comments
All the variables are declared and all the compare is ok....My problem is the button part....when the LCD display out "Pass....." i hold the program until i press the enter again...only it will run...but i need to press a lot of times only the program will loop back to the main......u get what i mean??
Main:
If in11=0 then main ' loop back if button not pressed
Hold:if in11 =1 then hold ' stay here until button released
etc...
' {$STAMP BS2pe} ' {$PBASIC 2.5} Main: IF (IN11 = 1) THEN IF (AD < refVoltage + (tolNumber/100) OR AD > refVoltage - (tolNumber/100)) THEN ' this line will compare the data. HIGH LEDGreen SEROUT RX,BAUD, ["Pass!! Enter to", CR, "continue."] 'PAUSE 10 DO WHILE IN11=0: 'IF (IN11 = 1) THEN LOW LEDGREEN GOTO main 'ENDIF LOOP ELSE HIGH LEDRED SEROUT RX,BAUD, ["FAIL!! Enter to", CR, "continue."] 'PAUSE 10 'DO 'IF (IN11 = 1) THEN LOW LEDRED GOTO main 'ENDIF 'LOOP ENDIF ELSE oddSign = 1 GOSUB convert GOSUB calc_volts GOSUB display PAUSE 500 GOTO main ENDIFMAIN2: DO SEROUT RX,BAUD, ["Enter to", CR, "run test."] DO : LOOP UNTIL IN11 ' wait for button up DO : LOOP WHILE IN11 ' wait for button down GOSUB convert ' do test and display GOSUB calc GOSUB display ' and show pass or fail LOOPThank you all for the reply and the comment given.... I had found the solution..Here is my new code and it works charmingly..i separate all the IF condition into subroutine.....anyone do not understand me please reply here... i will try my best to explain...thank you!!!!