Hello All, I have the following code running that sends high output to portb bit 5 And loops checking for a switch input on portb bit 7 the code turns off bit 5 when the switch is pressed and the dly20 in the code just delays 20ms for switch debounce. FINALWAIT BSF PORTB,RB5 BTFSC PORTB,START_PB GOTO FINALWAIT CALL DLY20 BTFSC PORTB,START_PB GOTO FINALWAIT BCF PORTB,RB5 CALL WAITSTARTUP GOTO EE2D This code works good but what I need to do is have the output (portb,5) get turned off after a given amount of time like 10-15sec, sort of a timeout if the switch never gets pressed, my problem is that it seems that if I take the bsf,portb,rb5 out of the finalwait loop, then the bit seems to go high and then reset? Port B,5 is driving a relay which latches in the above code but as I said, if I take the bsf porb,rb5 out of the loop then the relay seems to come up and then drop. Are the outputs on a 16f84 latching or does the output have to be in a loop in this case. Is there some other way to do the above in code that would implement a timeout if the switch never gets pressed. Any help would be great. The code below should give me aprox 15 seconds wait, this code does time out the output when implemented into the above code but the relay doesn't stay up for the whole time it seems to come up once and then drop. MYWAITSEC BSF PORTB,RB5 MOVLW H'0f' MOVWF SECNT2 ; MYWAIT MOVLW D'250' CALL NMSEC BTFSS PORTB,START_PB RETURN MOVLW D'250' CALL NMSEC BTFSS PORTB,START_PB RETURN MOVLW D'250' CALL NMSEC BTFSS PORTB,START_PB MOVLW D'250' CALL NMSEC BTFSS PORTB,START_PB ; RETURN ; DECFSZ SECNT2,f ; GOTO MYWAIT ; RETURN Thank You, Steve -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.