Concepts · Capacitors and RC timing

RC versus a bouncing switch

Mechanical buttons chatter when pressed, and a small resistor and capacitor can clean up that noise before the processor sees it.