I thought @LarryD's diagram about wiring was good:
Wokwi - Online ESP32, STM32, Arduino Simulator
Also:
And there are good references at
- Gammon Forum : Electronics : Microprocessors : Switches tutorial -- @nickgammon on the differences, software and hardware debouncing. Shows an oscilloscope plot of debouncing an Uno with 1uF capacitor for a 36ms response.
- https://www.ganssle.com/debouncing-pt2.htm -- Jack Ganssle on the details of debouncing. (part 1 on bouncing with lots of plots of different switches.)
- Using Digital Inputs -- switches & buttons @johnerrington on the behavior of digital inputs
- Switch bounce and solutions to it by @johnerrington.
Also, there is a completely different example for INPUT_PULLUP wiring:
https://docs.arduino.cc/built-in-examples/digital/InputPullupSerial/
