A while ago in December, I posted something at hackaday.com: a rhythmic door lock. I had in mind to use a keypad at the beginning, but I didn't have enough buttons and wanted to keep this a very low-budget project. For instance, the buttons were free samples and the filter capacitor was pulled from a TV or CRT monitor, I can't remember which.
Being limited to two buttons, I drew inspiration from other hackaday projects to make a rhythm-based code system. The rhythm must fulfill two criteria to be accepted:
- It must have the right number of beats.
- The beats must be spaced correctly, +/- 30%. This algorithm measures the beats proportionally.
The brains behind this is the Teensy microcontroller, which is programmed via a direct USB connection. At the time I built this project, I didn't want to pay more for a programmer module, so this was good. Other parts were things I had lying around. The door strike was already installed, which made things easy.
I relied on interrupts for the buttons and the built-in delay functions to time the beats. Debouncing the inputs in software was awful, and I don't want to go through that again. Next time, hardware. Because the buttons would do different things at different times, I used function pointers in C to configure their behavior at different stages in the program.
If you want to see my code and learn more, see my Instructable and the Hackaday article about it.