Scott writes: > > Try this untested code: > > MOVF PORTA,W ;Get the current state of PORTA,4 > XORWF index_flag,W ;Compare to the saved state. > ANDLW 1<<4 ;Only interested in PORTA,4 > > SKPNZ > goto no_change > > ;Change in states was detected > XORWF index_flag,F ;Save state for next time. > > ;"Index_now" code goes here. > > >no_change Thanks for the new method. I had to change it a little since it detected both edges and I needed falling edges. This is what I came up with: MOVF PORTA,W ;Get the current state of PORTA,4 XORWF index_flag,W ;Compare to the saved state. ANDLW 1<<4 ;Only interested in PORTA,4 SKPNZ goto Dont_care ;Change in states was detected XORWF index_flag,F ;Save state for next time. btfsc index_flag,F ;only want falling edges goto Dont_care ;"Index_now" code goes here. This is much better than my two methods, because changing it from detecting rising edges to falling edges only requires one change, from btfsc to btfss. I will also look at your debounce code on your web page. Thanks, Bob