Hundred1906
Member
I am using the Button command on a 14M2, (pin c.3) inside an independent task.
The effect being sought is to wait until a switch has been pressed for a few seconds and thereafter increment a delay value for each couple of seconds it remains depressed. This can be done using the Delay and Rate options in the Button command.
What I cannot get my head around is how to detect when the switch has been released. Some guidance would be helpful because the answer is probably in the functional description but passing me by.
Putting a conditional test inside the action address code doesn't work because the program only ever gets to that point when the switch is depressed.
I have searched the forum for previous comment because I believe there was once a long thread on the Button topic though I have not yet found it. Most comments advise using an interrupt instead, but I don't think I can do this on pinc.3 of a 14M2 because the SETINT guide says "14M/14M2 only inputs 0,1,2 may be used" and I have no other spare pins.
My test code is:
The effect being sought is to wait until a switch has been pressed for a few seconds and thereafter increment a delay value for each couple of seconds it remains depressed. This can be done using the Delay and Rate options in the Button command.
What I cannot get my head around is how to detect when the switch has been released. Some guidance would be helpful because the answer is probably in the functional description but passing me by.
Putting a conditional test inside the action address code doesn't work because the program only ever gets to that point when the switch is depressed.
I have searched the forum for previous comment because I believe there was once a long thread on the Button topic though I have not yet found it. Most comments advise using an interrupt instead, but I don't think I can do this on pinc.3 of a 14M2 because the SETINT guide says "14M/14M2 only inputs 0,1,2 may be used" and I have no other spare pins.
My test code is:
Code:
Start3: ;read button
b6=0
b4=0
buttonwait:
button c.3,1,5,2,b6,1,pushed
pause 1000
goto buttonwait
pushed:
if hoursdelay < 9 then
inc hoursdelay
else
hoursdelay=0
endif
if pinC.3 = 0 then
goto Start3 ; this never happens!
else
goto buttonwait
endif
end