Project 9: Detect a Knock on a Sensor (Knock)

Created on: 2 August 2012
Updated on: 17 January 2023

Tutorial 10 – Pages

A piezo sensor is connected to analog pin A0 of the Arduino. When the sensor is knocked or tapped, the on board "L" LED lights up and the message "Knock!" is sent out of the serial port for display in the Arduino IDE serial monitor window.

The circuit is built on breadboard in this easy Arduino Uno tutorial for beginners. One of the example sketches from the Arduino IDE is used to program the Arduino board.

Parts Needed

Besides an Arduino Uno or compatible board, USB cable, breadboard and wire links, you will need:

  • 1 × Piezo disc
  • 1 × 1M ohm resistor (1 meg ohm)

As an Amazon Associate I earn from qualifying purchases:

Arduino Website Page


Project 9 Video

The video below demonstrates the Arduino knock project. Each time the piezo disk is tapped or knocked, the word "Knock!" appears in the Arduino IDE serial monitor window.

In the Arduino IDE

File → Examples → 6.Sensors → Knock

Building the Circuit

The circuit diagram and breadboard connections can be found on the Knock Arduino website page.

Programming and Operating the Circuit

Find the sketch for this project under File → Examples → 6.Sensors → Knock in the Arduino IDE and upload it to the Arduino board.

Open the serial monitor window in the Arduino IDE. Tap or knock on the piezo sensor to see the on-board LED light up and the "Knock!" message sent to the serial monitor window.