- Texas Instruments LM386
- 1 kΩ resistor (x2)
- 33 kΩ resistor
- 10 kΩ resistor
- 2N3904 NPN transistor
- 1N4001 diode
- 0.1 µF ceramic capacitor
- 68 µF electrolytic capacitor
- 9 V battery w/ leads
- Copper strips/tape (or similar) to create a switch
Give this project a try for yourself! Get the BOM.
I love surprising my family with presents during the holiday season, but we all know some people who get a kick out of spoiling the surprise by taking an early peek. I personally have had repeated trouble with my mom snooping around under the Christmas tree. So this year I wanted to nip the problem in the bud with the help of a little brainpower and some electronic components. Thanks to a previous article found on AAC, I was able to throw the solution together fairly quickly, especially since this particular circuit doesn't require a processor or any exotic hardware.
Now every time my mom thinks I'm not looking, she'll quickly realize that I'm serious when I say "Don't Open Til Christmas." When she lifts the present from the two conductive strips, the object-detecting "switch" will open; this causes the oscillator circuit to become active, which in turn causes the alarm to sound. Now I can catch her in the act.
This project is based on a 1 kHz square wave oscillator circuit found in the datasheet for the Texas Instruments LM386 audio power amplifier IC (integrated circuit). This circuit generates the audio signal that we send to the speaker. We turn this oscillator on and off using a simple circuit consisting of a resistor, an NPN transistor, and (in my implementation) a diode.
If you look at the circuit in the original article, you won't see a diode. If the original circuit works for you, fantastic, but it didn't work for me. With my first attempt, the oscillator was active when the object-detecting switch was open and when it was closed. In other words, the speaker generated sound when the object was removed (as desired) and when it was in place (not desired). The sound was quieter when the object was in place, but not nearly quiet enough.
With some experimenting I found that inserting a diode between the transistor base and switch, with the cathode facing towards the switch, eliminated the undesired sound and allowed the circuit to function as intended. I don't know exactly why this works, but it appears that the diode's voltage drop causes the bipolar junction transistor (BJT) to conduct small amounts of current. In this state, it effectively disables the amplifier, whereas the amplifier seems to find an alternate current path when the BJT is in cutoff. This is the reality of electronics—sometimes you fix things without knowing exactly why the fix works.
1 kHz square wave oscillator with switch and diode fix. Click to enlarge
Okay, now that that's out of the way, let's dive in! We use R1 and R2 to produce positive feedback, creating a bistable multivibrator. What this means is that the IC will always end up in one of two stable states—saturation at the positive rail or saturation at the negative rail. If we left the circuit like this, the output would just get "stuck" in one of these states. To make a circuit that oscillates, we need to change it so that it automatically switches back and forth between the two stable states.
We accomplish this by creating negative feedback via C2 and R4. The circuit will now repeatedly switch output states as the voltage across the capacitor gradually increases or decreases following an output transition. Now our circuit is an astable multivibrator.
To enable and disable oscillation, we use a transistor to interrupt the current flow from the amplifier's negative supply pin to ground. Theoretically, this should power down the amplifier and thus disable oscillation. But, as discussed above, it didn't quite work this way for me.
A square wave, courtesy of Sparkfun
To create my switch, I used three metal strips from an Erector Set, but you can use anything conductive that will make a solid connection. If you don't have anything handy, I suggest using copper tape. Essentially, two isolated strips sit parallel to each other—one connected to the base of the transistor through the diode and the other connected to ground.
To close the switch, place the third conductive strip on the object you wish to protect and set it on top of the metal strips. Removing the object creates an open switch. For my project, I placed the third conducting strip on the bottom of a present.
Though the strips look connected, they are electrically separated by rubber gaskets
When the object is placed on top of the metal strips, the switch is closed, the base of the BJT is at 0.7 V, and only small amounts of current can flow from the collector-emitter. When the object is removed, the switch opens, resulting in higher current flowing into the base and thus higher current flow from collector to emitter. With current flowing freely from the negative supply terminal to ground, the oscillator is active and sound is generated by the speaker.
Now you can be the next Kevin McCallister!
Other MIT-i Innovations:
- The Cat-Apult! (an Arduino-controlled servo for makers)
- The Launchpad-Based Laser Tripwire Alarm! (a Launchpad security system)
- The Arduino UNIVERSAL Remote Control! (an IR receiver for your entire house)
- The Crop Duster Buster! (a clap-controlled odor-management system)
- The Traffic Light Controller! (an Arduino delay statement lesson)
- The Dancing Ghostbusters Toaster! (a lesson on solenoids and inductive loads)
- The Raspberry Pi Object Detection Cat Toy! (a lesson on the RPi GPIO)
- The Zambroombi! (an object avoidance robot)