latch on buttion

pittom

Active Member
Need help, In my program i want to set IP1 as momentary push button switch to turn OP1 on when IP1 is pressed (from "0" to "1" and back to "0" ) and stay on until IP1 is pressed again (from "0" to "1" and back to "0" ) then turn OP1 off
thanks
 
Just to be clear the code fragment posted by az1324 transitions on the button being pressed,which is what I assume you want to do.  However: the description you wrote implies you do not want output state to change until the button is released. If that is the case need to detect both button press and release states and update OP1 on the transition to 0..
 
Also: the code fragment needs to test for the button being released or it will toggle OP1 on/off as long as the button is depressed each time WC cycles through user code.
 
/tom
 
Good point more code needed.

TSTEQ IP1[10] RAM1
GOTO SKIP
TSTEQ IP1[10] 1 RAM1
XOR OP1 1 OP1
SKIP:

or possibly

TSTEQ IP1[10] IP1[200]
GOTO SKIP
TSTEQ IP1[10] 1
XOR OP1 1 OP1
SKIP:
 
Tom you are correct 
 transitions on the button being pressed,which is what I assume you want to do
 
az1324 i will try code thanks.did not think about GOTO SKIP
 
I tried this and it worked great thanks az1324
TSTEQ IP1[10] RAM1
GOTO SKIP
TSTEQ IP1[10] 1 RAM1
XOR OP1 1 OP1
SKIP:
 
Back
Top