We use a software debounce in many of our sketches. What’s a debounce? A mechanical switch does not make a clean on/off transition, and if you are sampling fast enough, one switch depression could look like several to the Arduino. The most common method of resolving this is to check the switch twice, and if there is no change, then consider it a true trigger. This incurs delays, and messy code. A hardware debounce uses a R/C circuit (resistor / capacitor) to deliver a single shot. Thanks to Jeremy Blum, we are also using a inverting Schmitt Trigger to clean up the output for a nice precise square wave. The M74HC14 has 6 inverters on board, so you could build a shield or carrier board with 6 debounced switches for very little cost. Just need one M74HC14, six 10k Ohm resistors, six 10uf capacitors, and six momentary on button switches. The M74HC14 has a GND connection on Pin 7 and a +5vdc on Pin 14, not shown below. The carrier board would only need +5vdc, GND, and 6 outputs to the Arduino.
Become the Maker you were born to be. Try Arduino Academy for FREE!