DIY Analog Alarm System with a TI LM386 Power Amp
By Ryan Jones
Although it was originally designed to make sure Christmas presents stay under the tree, this device will make a loud and annoying sound when somebody moves an object off of the pad.
- 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
I love surprising my family with presents during the holiday season, but there’s always that one family member who likes to take a sneak peak. I’ve had repeated trouble with my mom snooping around under the Christmas tree personally. So this year I wanted to solve that problem with the help of a little brainpower and some electronic components. I based my project off an Alarm System tutorial on All About Circuits. I was able to throw my solution together pretty quickly, especially since this circuit doesn’t require any exotic hardware or a processor.
Now, whenever my mom thinks I’m not looking, she’ll quickly realize that I mean business when I say “Don’t Open Til Christmas.” When she lifts the present from the two conductive strips, the object-detecting “switch” will open; which causes the oscillator circuit to become active, which in turn causes the alarm to sound. Now I can catch her in the act.
How Does it Work?
This project is based on a 1 kHz square wave oscillator circuit found in the Texas Instruments LM386 audio power amplifier IC’s datasheet (integrated circuit). This circuit generates the audio signal that is sent to the speaker. We can turn this oscillator on and off using a simple circuit consisting of an NPN transistor, a resistor, and (in my implementation) a diode.
If you look at the circuit in the All About Circuits tutorial, you won’t see a diode. The original circuit didn’t work for me. In my first attempt, the oscillator was active when the object-detecting switch was open and closed. In other words, the speaker made the sound when the object was removed (the intended function) and when it was in place (An alarm that constantly makes noise is not what I was going for). The sound wasn’t as loud when the object was in place, but it still made noise.
I inserted a diode between the transistor base and switch, with the cathode facing towards the switch. This eliminated the unwanted sound and allowed my circuit to function as intended. I’m not sure exactly why this works, but it appears that the diode’s voltage drop causes the BJT bipolar junction transistor to conduct small amounts of current. In this state, it effectively disables the amplifier. 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.
Okay, now that we have that out of the way, let’s dive in! We use R1 and R2 to produce positive feedback, this creates a bistable multivibrator. This means 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 were to leave the circuit like this, the output would get “stuck” in one of these states. To make a circuit that oscillates, we need to change it to automatically switch back and forth between the two stable states.
We can accomplish this by creating negative feedback via C2 and R4. Our 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. In theory, this should power down the amplifier, thus disabling oscillation. But, as discussed above, it didn’t quite work this way for me.
A square wave, courtesy of Sparkfun
I used three metal strips from an Erector Set to create my switch, but you can use anything conductive that makes a solid connection. If you don’t have anything handy, I suggest using copper tape. Essentially, there are two isolated strips sitting parallel to each other—one is connected to the base of the transistor through the diode and the other is 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 alarm, I placed the third conducting strip on the bottom of a wrapped present.
Though the strips look connected, they are electrically separated by rubber gaskets
When the present (Or whatever item you would like to guard) is placed on top of the metal strips, the switch closes, the base of the BJT is at 0.7 V, and only small amounts of electrical current can flow from our collector-emitter. When the present is removed, the switch opens, which results 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!
More Analog Projects
- DIY FM Transmitter
- DIY Bench Tools: Build a Signal Generator
- Build a DIY Spy Microphone: The Acoustic Telescope
Other MIT-i Innovations
- DIY Obstacle Avoiding Robot with Arduino and Ultrasonic Sensor
- DIY Cat Toy with a Raspberry Pi, LDR, and DC Motor
- Use an Arduino and Solenoid to Make a Toaster Dance
- DIY Arduino LED Traffic Light Controller
- Use a TI LaunchPad to Activate a Fan or Just About Anything!
- DIY Universal Remote with Arduino
- Laser Diode Tripwire Alarm with Launchpad
- Arduino Servo Catapult: DIY Catapult using Arduino