Knock Detection Sensor Arduino

Knock Detection

Here we use a Piezo element to detect sound, what will allow us to use it as a knock sensor. We are taking advantage of the processors capability to read analog signals through its ADC – analog to digital converter. These converters read a voltage value and transform it into a value encoded digitally. In the case of the Arduino boards, we transform the voltage into a value in the range 0..1024. 0 represents 0volts, while 1024 represents 5volts at the input of one of the six analog pins.

A Piezo is nothing but an electronic device that can both be used to play tones and to detect tones. In our example we are plugging the Piezo on the analog input pin number 0, that supports the functionality of reading a value between 0 and 5volts, and not just a plain HIGH or LOW.

The code example will capture the knock and if it is stronger than a certain threshold, it will send the string “Knock!” back to the computer over the serial port and also blinks the Pin 13 LED.

Piezo Knock Sensor

Piezo Knock Sensor
Piezo Knock Sensor

Arduino Knock Detection Circuit

Arduino Piezo Knock Detection Circuit
Arduino Piezo Knock Detection Circuit

Arduino Knock Detection Code

Knock Detection Result

                Open serial monitor, when you tap on the table or sensor Red LED (13) will blink and on serial monitor “Knock!” will be displayed.

Knock Detection Result
Knock Detection Result

Leave a Reply

Your email address will not be published. Required fields are marked *