Non-isolated input conditioning for a crude switch
standard practice is both of the following:


zener diode connected from outer input to ground
small resistor connected from outer input to CPU pin (20-100ohms?)


The zener diode clamps outer input between (ground - Vbe diode drop, where Vbe = between 0.7-1.0V) and (ground + zener clamp voltage at high current). The small resistor helps limit current from outer input into CPU pin.

ESD-clamping diodes (more commonly known as TVS = transient voltage suppressors; tons of companies make them, good mfrs are ON Semi and Diodes Inc and Fairchild) are really just zener diodes optimized for this use, that can handle high surge power w/o getting damaged. If you are concerned (or if you are working on a commercial product), I'd use one of them, but a regular zener will almost certainly work.

Make sure you use minimum wire/lead length from outer input to ground: the more inductance you introduce in series with the clamping diode, the worse it will perform.

(NOTE: regular zeners add capacitance, maybe a few hundred pF. If you have a communication line or other circuit node which is sensitive to capacitance, you'll need a special clamping diode that is designed for low-capacitance. These usually have the following topology internal to the part:

*-----+---&gt;Z------|&lt;------+------*
      |                   |
      +------&gt;|-----------+

 --&gt;Z--   = zener
 --&gt;|--   = regular diode


The regular diode in series with the zener reduces the capacitance, and you then need another diode in parallel with those two, in order to clamp in the other direction.)