I'm prototyping with a bunch of no name mechanical button mini-switches and SAM D21 microcontroller (Adafruit Feather M0). The switch is connected directly between the ground and the input pin #19 (PB02 of ATSAMD21G18) without any debouncing circuitry #19. This Arduino test program:
constexpr int BUTTON = 19;
void setup()
{
pinMode(BUTTON, INPUT_PULLUP);
}
void loop()
{
Serial << digitalRead(BUTTON) << ", " << micros() << "\n";
}
produces a log of clean transitions without a single bounce, e.g.
1, 8891998
1, 8892101
1, 8892197
1, 8892362
0, 8892468
0, 8892569
0, 8892668
0, 8892764
....
0, 9063951
0, 9064048
0, 9064145
0, 9064305
1, 9064401
1, 9064507
1, 9064610
1, 9064706
Pin PB02
is read more often than every 0.1ms, which seems sufficient to catch mechanical switch bounce. Is there some hardware filtering involved here? Unfortunately, I don't have a scope handy to capture the signal.
Here is a picture of the switch:
EDIT
There are several answers blaming serial port latency for missing the bounce. This is incorrect. I'm logging timestamps of each measurement, which are better than 4μs accurate. See https://www.arduino.cc/en/pmwiki.php%3Fn%3DReference/Micros for description of micros()
function, specifically: "On 16 MHz Arduino boards (e.g. Duemilanove and Nano), this function has a resolution of four microseconds".
EDIT'
Picture of the test setup, as requested (tiny switch on the left):