capacitor and pull up diodes or pull up resistor are used with any micro controller pins (not must with simple applications) but for advance and robust design it is necessary.
reason for that is micro controller is a high speed device it is very senstive about voltage levels so in many cases like sparking, short circuit , high frequency noise or other interfrence will shoot the false and unwanted triggering.
to minimize the interfrency decoupling capacitor is used.
A decoupling capacitor is a capacitor used to decouple one part of an electrical network (circuit) from another. Noise caused by other circuit elements is shunted through the capacitor, reducing the effect they have on the rest of the circuit.
because maximum noise is in the form of high frequency so to save the circuit from high frequency noise a bypass or decoupling capacitor is used with a specific value like 103pf which provide low very low reactance path for high frequency and therefore save the circuit from false triggering.
---------- Post added at 10:31 ---------- Previous post was at 10:29 ----------
**broken link removed**