A Maker by the name of Kyle has constructed a “Halloween knock box” powered by Atmel’s versatile ATtiny45 (or 85) microcontroller. According to Kyle, the box is fairly easy to put together, as basic components include an MCU, a piezo element (amplifier) for the knock sensor and a motor to provide the knocking feedback.
“The motor I originally tried was a cheap 6v [unit] for $2 or $3. Unfortunately, it didn’t have enough torque to move the weighted end and it had several ‘dead’ spots where it wouldn’t engage,” Kyle explained in a recent blog post. “I had even taken careful measurements of the motor’s dimensions and transferred them to Sketch-Up where I created a motor mount and later printed it in ABS. In the end, I rummaged through my junk boxes and found a motor that seemed small enough to fit.”
To make the knocking sound, Kyle took a small section of 12 gauge wire (about 1.5″) and made two loops – one for the knocking end and the other to mount to the motor.
“I used a hammer to tap the loop end of the wire over the motor shaft and used some super strong double stick tape to adhere the motor to the box. I had problems with the motor not returning fast enough and the knocking sound being too quiet,” he continued. “To fix this I put a weight (in this case a bolt) on the end. This gave it more than enough momentum to move the box and allows the motor to return fast. To get rid of that annoying clunk sound when it returns to the resting position, I glued some foam to the back of the weight.”
As noted above, electronic components for the Atmel powered Halloween knock box include a driver for the motor (simple 2n2222 transistor with a protection diode) and an amplifier for the piezo element, the latter of which allows the circuit to detect quieter knocks.
“The amplifier consists of a NTE490 MOSFET which was measured to have a threshold voltage of 1.7v,” said Kyle. “[Meanwhile], the gate is biased at just under 1.7v by a series of 7 diodes and a 11MΩ current limiting resistor. The current is so small that the diodes don’t fully conduct and as such, only drop about 230mV each.”
Once Kyle was satisfied with the operation of the circuit, he drew up a quick board in DipTrace and laid out the board in just under 1.5″x1.0″, allowing it to neatly fit on the smaller side of the box. The board was subsequently etched and populated, with Kyle continuing to test the microcontroller on the breadboard.
“On the software side of things, the microcontroller sleeps while waiting for a knock to trigger an interrupt. Once triggered, TIMER1 begins counting. When the next knock occurs, the current TIMER1 value is recorded in an array and TIMER1 cleared for the next knock. This repeats until either TIMER1 overflows or the array is filled,” he added. “If the overflow event occurs, then the knock timed out and it begins repeating the pattern back with the motor. A special event occurs when either 13 or 20 knocks are registered. When the first occurs, the box plays the Addam’s Family theme song. When the latter occurs, then the box waits for 15 seconds, then randomly begins knocking at the box for 30 second.”
Interested in learning more about building an Atmel powered Halloween knock box? You can check out a detailed breakdown of Kyle’s project here.