Box with a Music Lock using ATMega328P Microcontroller

Music LockThere are a lot of locks out there. There are locks open with a key, with a combination of digits, with various bodily parts, or with a correct geolocation. I decided to make a lock that I have not seen yet. Since I am learning to play piano an idea for this project came quite naturally. I decided to make a box that would open only if a correct tune is played.
This instructable talks about an algorithm that I used, circuit design and box design. But first, here is a video that illustrates how it all works together:


Before getting into the details of project design, allow me to give a brief 101 on the theory behind tune detection.
As you might know sound is just air pushing against nerves in our ears. An air wave pushes – a nerve tracks the irritation. What we hear as a note are actually these air pushes with a constant period. In other words, if the nerve is tickled 130 times a second one hears a “C”.
Devices that detect notes try to figure out how many times a second its microphone was “tickled”, what was the frequency. Figuring out what note corresponds to what frequency is simple because there are “frequency → note” tables.
There are several algorithms that transform data read from a microphone into a frequency. The most prominent is a Fourier transform. The idea is quite simple: an input to is how strong was the air pushing in any given point in time. An output is how much of each frequency was contained in the input.  I think it is best explained by a picture attached to this step.
It is obvious that you can detect a tune using this algorithm. However, a music lock project can be a little more efficient. We don’t really need to know how much of each frequency the input contained. We just care if the input had a frequency of a note we are detecting. For instance, if the first note of our unlock sequence is D, we don’t care how much A’s or B’s were in the input. We just need to know if D was there.
This is when Goertzel algorithm comes in handy. It is used to identify one target frequency. As a matter of fact, it is used in telephones to recognizes the tones produced by the buttons pushed on a telephone keypad.
For more Detail: Box with a Music Lock using ATMega328P Microcontroller


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

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

Scroll to Top