David Olson wrote: > However, if I hold the button down (RA1 is high), I get a flashing LED > (RB1) - because it's toggling on and off. (Rubs hands together - figuratively!) Oooh! The Debounce algorithm! Four switches eh? OK, match them with four bits in a register which we call "previous", and a 4-bit variable called "count". It should be fairly obvious that one byte can be used for both. You examine the switches and pass through the algorithm every two milliseconds or so. The rest of the time you go do something else, you do *not* wait in the routine. On each pass, you note whether all of the switches match "previous" (XOR). If they do, you set "count" to $F. If they do not, you decrement "count". If in doing so, "count" becomes zero, then you examine the switches, one at a time, to see which does not match "previous". The first one that does *not* match previous has the corresponding bit in "previous" set to match the current state of the switch, the *action* corresponding to this switch being actuated or released is performed accordingly, and "count" is incremented (back to 1) (or may be reset to $F). Depending on how you wish your timing loop to perform, you may at this point proceed to your "other" task for a further 2 ms, or loop back and find any other switch that does not match "previous". In either case, if there was only one switch changed (and most of the time, there will only be one), the next iteration finds the switches match "previous", and "count" is reset to $F. Is this clear enough? -- Cheers, Paul B.