One pres switch in pic basic help!!!!
Hay,all!!!!
Can somebody help me in Picbasic programing!
I need some code to switch with one button,to change to next program!
Example:
program1:
some doing
goto program 1
program2:
some doing
goto program2
program3:
some doing
goto program3 .......
and can some help me how I write some code for the button,when I press button ONE TIME,to I change to
program1
program2
program3......
to change program,when I PRESS MY BUTTON ONE TIME,TO AUTOMATIC GO TO CHANGE PROGRAM!
If some body can help me,how i do that un PIC BASIC!
Program selection by button press
Try this idea, it works with PBP in a PIC18F4620 and should work with any PIC that has EEPROM.
I set a byte variable "ProgramState" to 1 in a data statement and write this to EEPROM when the program is loaded into the PIC.
At power up, the code reads the value stored in ProgramState, EEPROM location 0, here set to 1, and jumps to the appropriate code block.
MAIN:
READ 0, ProgramState
If ProgramState = 1 then RunCode1
If ProgramState = 2 then RunCode2
If ProgramState = 3 then RunCode3
If ProgramState > 3 then
write 0, 1 'reset ProgramState to first code block
goto MAIN
endif
RunCode1:
execute codeblock 1
if ButtonDown = 1 then
write 0, 2
endif
goto MAIN
RunCode2:
execute codeblock 2
if ButtonDown = 1 then
write 0, 3
endif
goto MAIN
etc
HTH
BrianT