|Why are pull-up resistors used? I am interfacing a keypad to a |PIC16C84, I understand I can set the internal pull up resistors but I am |not sure why they are needed. |Typically what value would I use for an external pull-up? First of all, because Microchip saw the need for pull-ups in certain applications, they provided a handy feature which can connect pull-ups to all of the PortB pins internal to the PIC, obviating the need for external pull-ups in many cases. Clearing bit 7 of the option register will enable pull-ups on all PORTB pins that are set for input. That having been said, pull-ups are a means of ensuring that a signal that is not actively being driven will assume a default "high" state; pull-downs cause such signals to assume a default "low" state. When scanning keyboards and such, the normal condition of the input wires is that nothing is connected to them (unless a key is pressed). Using a pull-up resistor will ensure that the input is at a known (high) state. Otherwise, the input's behavior when nothing is connected is unpredict- able(*). (*) There is a trick for keyboard scanning on the PIC which may allow you to avoid using pull-ups, and which may also provide for somewhat more-robust- than-normal detection of kepresses when the key contacts are dirty. It does, however, require that keys be scanned and detected multiple times to avoid false hits. Here's the trick, assuming a 4x4 keyboard wired with rows on PORTB4-7 and columns on PORTB0-3. Set PORTB all to actively-driven high Float PORTB0-3 and ground one of PORTB4-7 Read PORTB0-3. Any pins that have gone low currespond to likely-pressed buttons on the row you just grounded. Set PORTB to all actively-driven low Float PORTB0-3 and drive one of PORTB4-7 high. Read PORTB0-3. Any pins that have gone high correspond to likely-pressed buttons on the row you just drove high. By repeating this procedure with each row on PORTB4-7, you can scan the entire keyboard. Any key whose CAPACITANCE is substantially greater than the PIC's port pin's capacitance and that of un-pressed keys on its column will be detected even if the contact is poor. Adjusting the amount of time before the "read"s wll change the sensitivity of the device; with a bit of effort, excellent reliability should be obtainable. Note, though, that any keyboard designed with this approach should be tested in conditions of vari- able humidity since humid environments may cause false-tripping if the device is too sensitive.