Thanks,but when I use this code:
ButtonPressCounter = 0
SWITCH-LOOP:
IF PORTA.2 = 0 THEN
IF ButtonPressCounter = 3 THEN ButtonPressCounter = 0
ButtonPressCounter = ButtonPressCounter + 1
IF ButtonPressCounter = 1 THEN GOSUB Program1
IF ButtonPressCounter = 2 THEN GOSUB Program2
IF ButtonPressCounter = 3 THEN GOSUB Program3
ENDIF
GOTO SWITCH-LOOP:
Program1:
high portb.1
RETURN
Program2:
high portb.2
RETURN
Program3:
high portb.3
RETURN
WHEN I TRY COMPILE IN PIC BASIC,THEN GIVE ME THIS ERRORS!
ERROR Line 1: Syntax error.
ERROR Line 3: Syntax error.
ERROR Line 4: IF without a matching ENDIF.
ERROR Line 5: Bad expression.
ERROR Line 5: Bad expression or missing THEN.
ERROR Line 5: IF without a matching ENDIF.
ERROR Line 6: Syntax error.
ERROR Line 7: Bad expression.
ERROR Line 7: Bad expression or missing THEN.
ERROR Line 7: IF without a matching ENDIF.
ERROR Line 8: Bad expression.
ERROR Line 8: Bad expression or missing THEN.
ERROR Line 8: IF without a matching ENDIF.
ERROR Line 9: Bad expression.
ERROR Line 9: Bad expression or missing THEN.
ERROR Line 11: Syntax error.
I DO NOT NOW WHY,WHAT IS HAPPENED?
Is that the whole code?
Is the line
in there someplace?Code:ButtonPressCounter VAR BYTE
Dave
Always wear safety glasses while programming.
Thanks,for help,but can you give me one more answer!
I write this code:
ButtonPressCounter var byte
SWITCHLOOP:
IF PORTA.2 = 0 THEN
IF ButtonPressCounter = 3 THEN ButtonPressCounter = 0
ButtonPressCounter = ButtonPressCounter + 1
IF ButtonPressCounter = 1 THEN GOSUB Program1
IF ButtonPressCounter = 2 THEN GOSUB Program2
IF ButtonPressCounter = 3 THEN GOSUB Program3
ENDIF
GOTO SWITCHLOOP:
Program1:
high portb.1
PAUSE 500
LOW PORTB.1
PAUSE 500
RETURN
Program2:
high portb.2
PAUSE 500
LOW PORTB.2
PAUSE 500
RETURN
Program3:
high portb.3
PAUSE 500
LOW PORTB.3
PAUSE 500
RETURN
is Ok,code working,
but how I do it,when I switch button,to change program,and stay work in this some of this program?
Sorry, but I do not understand the question.but how I do it,when I switch button,to change program,and stay work in this some of this program?
Dave
Always wear safety glasses while programming.
I try ex plane,my question!
I mean!
I need when I press button one time,
then in my case go to program1,
and still working in program1!
When I press button second time then
go to program2,
and still working in program2,
When I press button 3.rd time then
go to program3,
and still working in program3,......
Maybe...
maybe not... See what happens.Code:SWITCHLOOP: IF PORTA.2 = 0 THEN ButtonPressCounter = ButtonPressCounter + 1 IF ButtonPressCounter = 1 THEN GOSUB Program1 IF ButtonPressCounter = 2 THEN GOSUB Program2 IF ButtonPressCounter = 3 THEN GOSUB Program3 IF ButtonPressCounter = 4 THEN ButtonPressCounter = 0 ENDIF GOTO SWITCHLOOP:
Dave
Always wear safety glasses while programming.
Bookmarks