1968neil
Senior Member
Hi Guys,
Have a minor problem that i cant get my head round.
If you look at the attached code in the last loop "keepalive" i need the code to sit in that loop until the switch is pressed again.
any suggestions or am i missing something basic ?
Regards
Neil
The code:
symbol led = 4
symbol op1 = 1
symbol op2 = 2
symbol pbswitch = pin3
symbol down = 0
symbol counter = b0
counter = 0 'initialise counter
loop1:
if pbswitch = down then switchdown ' is switch pressed
branch counter, (talkthruoff, talkthruon) 'branch on counter state
counter = 0 'reset counter
goto loop1
switchdown:
counter = counter + 1 'Increment counter
sdloop:
if pbswitch = down then sdloop ' wait til switch released
goto loop1
talkthruoff:
low led
low op1
high op2
pause 500 'wait 500ms
high 0 'output high on 0
pause 250 'wait 250ms
low 0 'output low on 0
goto loop1
talkthruon:
high led 'led on
high op1 'op1 on
low op2 'op2 off
goto keepalive
keepalive:
high 0
pause 1000
low 0
goto loop1
Have a minor problem that i cant get my head round.
If you look at the attached code in the last loop "keepalive" i need the code to sit in that loop until the switch is pressed again.
any suggestions or am i missing something basic ?
Regards
Neil
The code:
symbol led = 4
symbol op1 = 1
symbol op2 = 2
symbol pbswitch = pin3
symbol down = 0
symbol counter = b0
counter = 0 'initialise counter
loop1:
if pbswitch = down then switchdown ' is switch pressed
branch counter, (talkthruoff, talkthruon) 'branch on counter state
counter = 0 'reset counter
goto loop1
switchdown:
counter = counter + 1 'Increment counter
sdloop:
if pbswitch = down then sdloop ' wait til switch released
goto loop1
talkthruoff:
low led
low op1
high op2
pause 500 'wait 500ms
high 0 'output high on 0
pause 250 'wait 250ms
low 0 'output low on 0
goto loop1
talkthruon:
high led 'led on
high op1 'op1 on
low op2 'op2 off
goto keepalive
keepalive:
high 0
pause 1000
low 0
goto loop1