David BALDWIN wrote: > As usual, I have some questions today... I am using the check_keys > routine from Bob Blick. In fact, it only detects falling edges on portA. > I am searching for a routine that could decide between a single press on > a switch and a long press on a switch (more than 500ms or 1s). David, Check out my debouncing routine to capture both edges: http://www.interstice.com/~sdattalo/technical/software/pic/debounce.html A simple way to check if a key is pressed for a "long time" is with the following untested code: MOVF previous_state,W ;Get the previous state of the ;switch (i.e. the last time it was ;debounced). XORWF latest_state,W ;Get the latest state of the switch XORWF previous_state,F ;Save latest state as previous state ANDLW BIT_POS_OF_SWITCH ;We're interested in this bit. SKPNZ ;or SKPZ if input is low on key press INCFSZ a_counter,F ;Detected a pressed key count it. CLRF a_counter ;No detection, so clear the counter. If this little chunk of code runs once every 5ms and you want to measure key presses longer than one half of a second, then you simply need to monitor when "a_counter" exceeds 100 (base 10). The state of the switch is the "debounced state". In other words, the debounce routine would first execute before this one. Anyone see the subtlety in the skips? Scott PS. John, CLRF DOES affect the Z-bit on 16Cxx parts too. You will have to make many, many, many more mistakes before any embarassment is warranted though.