Maker Pro
TI Launchpad

Make a Fan (or Anything) Clap-Activated With TI LaunchPad

April 08, 2017 by Ryan Jones
Share
banner

Use Texas Instrument's Launchpad to add sound activation to an electric fan.


This LaunchPad-based Crop Duster Buster is sure to keep your pet's farts away! Or at least you'll learn something about automating devices to be controlled by clapping. Don't you hate when you're sitting with a loved one and they let one rip without warning? You probably can't train your dog to hold it, but 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 with two hands, but you get the idea!)

Crop Duster Buster Clap-Activated Fan Diagram. View the full-size version.

Why?

I was sitting around peacefully watching my Sunday cartoons when I heard a strange noise emitted from beside me. Moments later, I smelled what that noise was. My first instinct was to move my cat, Olive, away from me. Unfortunately, after doing so, I realized that it was not enough to do the trick. I had to leave the room! That's where I drew the line. Nobody interrupts my television! But, I certainly don't watch TV without my cat by my side.

With some basic components lying around the house, I was able to create what I dubbed, the "Crop Duster Buster." Never again would I have to worry about the smell of my cat's high protein diet.

Olive is not amused with the invention...

How Does the Launchpad Clap-Activated Fan Work?

I based this project off of a tutorial for sound activated switches with LaunchPad. The first step was creating the microphone preamplifier. A very basic preamp is all that we need for this project, and the BJT-based circuit shown in the schematic will give us adequate results. However, if you're looking to do any serious audio work, you'll be better off using a solid op-amp based circuit (the MAX4465 is an op-amp optimized for microphone preamp applications).


The preamp circuit, combined with the analog-to-digital converter (ADC) in the Launchpad, allows us to convert sound into digital data ready for some basic signal processing. We'll need to program our Launchpad to detect voltage peaks that correspond to our claps. We can use the code below to collect ADC data for analysis; looking at some data will help us come up with an effective scheme for detection.

void setup()
{
Serial.begin(9600);
}
void loop()
{
 int sensorValue = analogRead(A0);
 // print out the value you read:
 Serial.println(sensorValue);
}

Our program tells the Launchpad to look for two claps within 500ms of each other that are above an adjustable threshold. Our pushbutton allows us to set the threshold to one of three predefined values. The yellow LED will get brighter as sensitivity increases. When the Launchpad detects the double clap pattern, it can perform whatever task we choose; for this project, it actuates a relay, which in turn powers our fan.

To turn on the fan, we just need a BJT, a resistor, a relay, and a flyback diode. An LED is included to notify us when our fan is on. (I used a 330Ω resistor for R7, which leads to an LED forward current of around 30mA; you'll want to use higher resistance if your LED can't handle that much current.) When our Launchpad detects two claps within 500ms of each other, it will turn on the transistor so current can flow through the LED and (Most importantly) through the relay coil.

If the preamp circuit seems like a bit much for you, or the smell is getting out of control, you can use a module that includes a microphone and a preamp.

Breakdown

  • Our preamp circuit converts audible sounds into an electrical signal with adequate amplitude for processing with the Launchpad.
  • Our Launchpad's ADC converts that electrical signal into digital data.
  • We tell our Launchpad to look for two claps within the predefined time interval.
  • When our LaunchPad detects the double clap, it sends a logic-high signal to the driver circuit, which activates the relay and powers the fan.
Download the Clap Activation Code for TI LaunchPad (Zipped)

Our relay is simply acting as an on/off switch, you actually can control anything around your house with this device, such as a television, stereo, or lamp! But remember, household voltage is dangerous. If you're not familiar with the relevant safety procedures and techniques, an alternative approach is to using something like this relay-controlled AC outlet.

Breadboard Setup

The possibilities are nearly endless. Dive deeper, find your inner maker and adapt this circuit and program to your needs. Remember to leave comments and show us pictures/videos of what you've made! Until next time, happy hacking!

Author

Avatar
Ryan Jones

Start my career as an Audio Engineer, now turned professional maker!

Related Content

Comments


You May Also Like