Hello and thank you in advance...
Well, I have a code that activate and deactivate two relays. This code is a state machine running depending on the values of a certain sensor. All automatically without human intervention.
I am trying to use a touch sensor that, when pressed and released, interrupts the code and execute a subrutine to turn off the relays and then do nothing, just wait until the same touch sensor is pressed and released again to resume the execution of the code.
To simplify the explanation we can imagine that the code just turn on and off the pin B.2 of the picaxe.
I have something like this but my code is a mess and I know there is a very simple way to achieve this but I can't find a simply logic
Please help me with ideas or examples. I am learning a lot and I am very happy to use this picaxe microprocessors.
Thank you so much,
Nanogear
Well, I have a code that activate and deactivate two relays. This code is a state machine running depending on the values of a certain sensor. All automatically without human intervention.
I am trying to use a touch sensor that, when pressed and released, interrupts the code and execute a subrutine to turn off the relays and then do nothing, just wait until the same touch sensor is pressed and released again to resume the execution of the code.
To simplify the explanation we can imagine that the code just turn on and off the pin B.2 of the picaxe.
I have something like this but my code is a mess and I know there is a very simple way to achieve this but I can't find a simply logic
Code:
setint %00001000,%00001000,C ; interrupt when pinC.3 goes high
symbol TOUCHCONFIG = %00001001
main:
high B.2
pause 1000
low B.2
touch16 [TOUCHCONFIG], C.4,w0 ; read value into w0
if w0 > 3600 then
high C.3
else
low C.3
endif
goto main
interrupt:
pause 500
high B.2
pause 1000
low B.2
if pinC.3 = 1 then interrupt ; loop here until the interrupt cleared
pause 1000
setint %00001000,%00001000,C ; re-activate interrupt
return
Thank you so much,
Nanogear
Last edited: