Hi,
Not quite sure I understand. Are you saying that you want it to execute one of the three loops depending on how many times the butten is pressed within a certain amount of time? Or are you saying that you want to execute the three loops, one after the other, but to wait for a button press between the loops?
In any case, I'm afraid what you have there ain't gonna work....
Code:
B_P_C VAR WORD
COUNT GPIO.5, 10000, P_B_C
The above will define a 16 bit variable called B_P_C and then immediatley start counting how many times the button connected to GPIO.5 is pushed. It will keep counting for 10 seconds (10000mS) after which it continues in the program.
What this does is to say that i should be assigned whatever value B_P_C is. So, after this is exectued i has the same value as B_P_C, provided i is declared the same size as B_P_C - a WORD in this case.
Code:
IF B_P_C = i GOTO FIRSTLOOP ' Button pressed once
IF B_p_c = i+i GOTO SECONDLOOP ' Button pressed twice
IF B_P_C = i+i+i Goto THIRDLOOP ' Button pressed a third time
Now, since i is the same as B_P_C (it is because you told it to be) the only condition that can ever be true is the first one.
/Henrik.
PS. Pushbuttons are quite "bouncy", the COUNT command may register several counts even though you only push the button once.
Bookmarks