text.skipToContent text.skipToNavigation

Secret Knock Detector

We saw this project on Instructables, and had to try it for ourselves. Of course, we ended up using all the Duinotech parts we had around. It uses a piezo transducer as a microphone to detect knocking, and then activates a relay if the correct knock sequence is detected. The original project was designed to unlock a door, but our version has a relay output which you could use for just about anything.

You'll need to visit the Instructables page and download the sketch file - we can't post it here because of copyright.


XC4414 Duinotech Nano Board
PB8817 Mini Breadboard with 170 tie points
WC6028 Plug-Socket Jumpers
XC4419 5V Relay Board
AB3440 Piezo Transducer
RR1656 2.2M Ohm resistors (anything in the megohms should work)
XC4428 RGB LED Module

knock detector


Most of the connections can be seen on the photo above, but note that D2 is connected to ground with a small loop of wire (we shortened one of the resistor legs and used an offcut). This keeps the Secret Knock Detector from entering programming mode. The resistor itself is connected between A0 and ground like the piezo, and can be just seen on the left of the Nano board between A0 and GND.


Relay Board


Piezo Function








Black Ground




Red Signal from transducer




  Red LED
D5   G   Green LED
    B   Blue LED - not connected
D3 S     Input for relay board
D2       Connect to ground

Compile and upload the code to the board, making sure the board type is set to Nano. Once the green LED comes on, knock on the table next to the sensor. It should blink off to indicate it is detecting the knock. It’ll probably then go off for a second- this means it didn’t detect a correct code. The default code is ‘Shave and a Haircut’.

You can also open the Serial Monitor in the Arduino IDE and monitor it’s output to see what the detector is detecting.


The Instructables page has some good suggestions on how the software can be changed, including printing out the code and changing the default code.

Using our LA5077 Electric Door Strike and an MP3486 12V Plug Pack, you could easily add this to a door.