Hi,
You say that if the button is pressed one time it should run the first loop - no problem there. But how fast should you need "double-click" or "tripple-click" it in order to run the second or third loop instead of the first one? Or should it run the first loop as soon as it sees a button press and THEN wait for the button the be pressed again?
With the count command but you need to understand that it counts for a certain amount of time during which nothing else will get executed, once that time has passed (10000ms in your case) the code will continue.
So, your idea was on the right track but the implementation had a couple of problems as explained in my previous message. Here's ONE aproach to the single, double, triple-click solution but remember that it might not work in reallity due to the switch bouncing as described before.
Let's say your button pulls the input low when pushed.
Code:
B_P_C VAR BYTE
WaitForButton:
If GPIO.5 = 1 THEN GOTO WaitForButton 'Button is not pressed, go back and check again
PAUSE 10 'Wait a little while for the contact bouncing to die
WaitForRelease:
If GPIO = 0 THEN GOTO WaitForRelease 'Loop here until button is relased
COUNT GPIO.5, 1000, B_P_C 'Count number of presses for during one second
IF B_P_C = 0 THEN GOTO FirstLoop 'Remember, we had to press the button once to get here.
If B_P_C = 1 THEN GOTO SecondLoop
If B_P_C = 2 THEN GOTO ThirdLoop 'First one press, then two more as counted by the COUNT-command.
Goto WaitForButton 'Start over if number of presses is more than 3
FirstLoop:
'Your code here
Goto WaitForButton
SecondLoop
'Your code here
Goto WaitForButton
ThirdLoop:
'Your code here
Goto WaitForButton
END
Now, wire it up, compile the code, program the chip and GIVE IT A TRY! ;-) If there's still "basic" stuff that you don't understand then you need to back up and get that sorted first or you will just be creating more problems for yourself. Perhaps we jumped to the LOOKUP and COUNT commands etc a little too soon(?).
/Henrik.
Bookmarks