I have a button and I want when I push it to go to labelone and when push again it to go to labeltwo , and so on.
I have a button and I want when I push it to go to labelone and when push again it to go to labeltwo , and so on.
Last edited by savnik; - 15th July 2006 at 22:06.
Just use a routine that sets a counter and then resets the next time. Branch depending on if the counter is 1 or 0. Put a time limit for the second if you want and have it reset at the expiration.
I would do it by interupting the pic and have an if statement:
if c1 = 0 then
do whatever
resume (whatever your base routine is)
do whatever else
c1 = 0
resume (whatever your base routine is)
in your base routine you could put the pic to sleep for a defined period of time and if it had not been interupted within that time make c1 = 0. That way if it were 1 it would clear it.
The use of an internal Counter may reduce the code size too... look for RA4/T0CKI. Just read the TMR0 register and play with.Code:CounterA Var Byte CounterA=0 Start: If PORTB.0=0 then If CounterA<=1 then CounterA=CounterA+1 else CounterA=0 endif endif While PORTB.0=0 : Wend : pause 50 BRANCHL CounterA,[LabelOne,LabelTwo,LabelThree] ' ' stuf and other ' Goto Main LabelOne: ' Stuff goto Main LabelTwo: ' Stuff goto Main LabelThree: ' Stuff goto Main
Last edited by mister_e; - 16th July 2006 at 09:36.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
I have this code in my programm:
LOOP:
Button CH,0,255,0,b3,1,UHF 'b3 var BYTE
Button CH,1,255,0,b3,1,VHF 'CH var PORTB.5
PAUSE 100
GoSub POSTING
GoTo LOOP
UHF:.................
.................
GoTo LOOP
VHF:.................
.................
GoTo LOOP
I want if push one time the button and release to go to UHF and if push again and release to go to VHF and if push again and release to go to UHF , and so on
Last edited by savnik; - 16th July 2006 at 08:26.
did you at least tried the previous?
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Yes , but not compileOriginally Posted by mister_e
If PORTB.0=0 then ' ERROR Line 133: IF without a matching ENDIF. (TUNER.bas)
If CounterA<=1 then
CounterA=CounterA+1
else
CounterA=0
Doh! corrected now.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Hi Savnik. Assuming you have your pushbutton on porta.0, you can toggle the variable "pushbutton" either 0 or 1 by making it a bit variable.
PUSHBUTTON VAR BIT
START:
IF PORTA.0 = 1 THEN START
IF PORTA.0 = 0 THEN LET PUSHBUTTON = PUSHBUTTON + 1
GOSUB WAITFORRELEASE
IF PUSHBUTTON = 0 THEN UHF
IF PUSHBUTTON = 1 THEN VHF
GOTO START
WAITFORRELEASE:
PAUSE 25
IF PORTA.0 = 0 THEN WAITFORRELEASE
RETURN
as title says ... you could find, between others, melanie's sweet words ...
Alain
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Hello,
I want to do the following thing, I have 2 pulsers one in rb0 and another one in rb1 and a LED in rb2 and rb3. I Need to on and off with the same pulser in rb0 the LED in rb2 and want to on and off with the same pulser in rb1 the LED in rb3.
Since I can do it. Thanks
Originally Posted by mister_e
Hello,
I want to do the following thing, I have 2 pulsers one in rb0 and another one in rb1 and a LED in rb2 and rb3. I Need to on and off with the same pulser in rb0 the LED in rb2 and want to on and off with the same pulser in rb1 the LED in rb3.
Since I can do it. Thanks
Originally Posted by savnik
Bookmarks