Don’t you hate when you’re sitting with your loved one and they toot without warning? While you can’t train your dog, Buster, to hold it in—you can create a device that will help supply fresh air to your personal space with the clap of a hand! (Okay, so two claps but you get the idea!)
BOM:
- Texas Instrument’s Launchpad
- Energia Software
- Electret Microphone
- 2N3904 NPN Transistor x2
- SPDT 5v Coil Relay
- 330R Resistor x2
- 1k Resistor x2
- 10k Resistor x2
- 100k Resistor
- 100nF Capacitor x2
- 1N4007 Diode
- LEDs x2
- Pushbutton
- A Pet or Loved One
Why?
While I was sitting there peacefully watching my Sunday cartoons, I heard a strange noise emitted from beside me. Moments later I smelled what it was. My first instinct was to nudge my cat, Olive, away from me and after doing so I realized that it didn’t do the trick. I had to leave the room! That’s where I drew the line. Nobody interrupts my television, and I certainly don’t watch TV without my cat by my side.
With some basic components that were lying around the house, I was able to create the “Crop Duster Buster.” Never again would I have to worry about the smell of my cat’s toots.
How?
Thanks to the original article, I was able to pull this project together rather quickly. The first step was to create the microphone preamplifier. A very basic preamp is all we need for this project, and we can get adequate results with the BJT-based circuit shown in the schematic. But if you’re looking to do any serious audio work, you’ll want to use a solid op-amp based circuit (the MAX4465 is an op-amp that is optimized for microphone preamp applications).
The preamp circuit, combined with the analog-to-digital converter within the Launchpad, allows us to convert sound into digital data ready for some simple signal processing. We will need to program the Launchpad to detect voltage peaks corresponding to the claps. We can use the following code to collect ADC data for analysis; looking at some data will help us come up with an effective detection scheme.
void setup()
{
Serial.begin(9600);
}
void loop()
{
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
}
Within our program, we tell the Launchpad to look for two claps within 500ms of each other and above an adjustable threshold. A pushbutton allows us to set the threshold to one of three predefined values. The yellow LED gets brighter as sensitivity increases. When the Launchpad detects the two-clap pattern, it can perform whatever task we choose; in this project, it actuates a relay, which in turn powers a fan.
Read More: The Crop Duster Buster! A Launchpad-Controlled Clapper