The Knock Switch Sensor Module (also known as Tap Module) is a mechanical sensor that detects knock or tap or vibration. It is almost the same behavior with our previous article using the Shock Switch Module. The only difference is that you have to apply more pressure or knock the module to trigger the desired output. The default desired output is LOW level (same with Shock Switch Module). This mechanical knock sensor in the module contains a coiled spring in a clear plastic housing and a pull-up resistor.
Note: If you want to reverse the desired output, from LOW level to HIGH level, you just interchange the connection of the GND and the power line (middle pin).
Code example for Knock Sensor Module
Upload the code to Arduino and test the knock sensor module. Tap harder. Once it detects the impact, the LED will turn on.