
If you want to input a manual switch signal into a digital circuit you'll need to debounce the signal so a single press doesn't appear like multiple presses.
There is a Bounce library for Arduino which is very easy to use. However there is limitations with this Bounce library.
- You are unlikely to enable the internal pull-up resistor on switch pins, therefore each switch require an external pull-up resistor
- It is not possible to detect the switch state before main loop (setup). When you press a switch during power on, you will never get the state of the switch.
Adafruit wrote an example code for multi-button checker with debouncing which will solve that two problems.
I'm modifying the example code, it is useful if you want something to only happen once when a button is pressed.