1) Filtering
This circuit can be used to protect the I/Os of microcontrollers/ processors. D1A is used for Transient Voltage Suppression or ESD protection. R1 acts as a current limiting resistor as well as a low pass filter together with C1. The value of the resistor and the capacitor must be sized so that the microcontroller does not miss any signals.
The rise time of the fastest income edge = 2.2 RC
2) Limiting Current
This circuit limit the input current to 23.2 mA (VZ/R1 = 5.1 / 220).
3) Limiting Voltage
Use Schottky diodes with 0.2 Vf for better performance. Once the voltage at the I/O pin is greater than VCC by about 0.2V, the top diode will start to conduct. The bottom diode will conduct for a voltage less than -0.2V.