Electret Mic Breakout Board Hookup Guide
The Windbag Alert
Do you have a co-worker that talks too much? Do you want to alert that long-talker in your life of their offenses with the least unassuming desk ornament? Do you like literal translations of bad expressions? Then make yourself a Windbag Alert. This rude little piece of hardware will inflate a bag (one of my doggy doop-doop bags) with the air of your stolen silence.
Here the bag is deflated but the Electret Mic is listening. If ADC values are above a certain threshold for too long the bag will begin to inflate.
Here, someone has been talking for about 30 seconds. They have just a few seconds before the bag fully inflates. The fan kicking on usually stops them dead in their tracks.
But, some people, those people, don't care. And the bag completely inflates. Alerting that person they are indeed the office Windbag.
Let's break this thing down. This project is simply a continuation for the LED Blinking project from the previous section.
Hardware
I used a 12V computer fan, because that's what I had laying around. You can use any fan, even disassemble a hand held cooling fan found at dollar stores.
I used an old SparkFun box as my project enclosure, which sits on my power supply on my workbench. I wrapped a plastic bag around the computer fan using electrical tape. There is about 1/2" of space between the box top and fan. I used standoffs there. Make sure there is enough air flow.
Software
language:c
const int sampleWindow = 250; // Sample window width in mS (250 mS = 4Hz)
unsigned int sample;
int Wind = 9;
void setup()
{
Serial.begin(9600);
pinMode(Wind, OUTPUT);
}
void loop()
{
unsigned long startMillis= millis(); // Start of sample window
unsigned int peakToPeak = 0; // peak-to-peak level
unsigned int signalMax = 0;
unsigned int signalMin = 1024;
// collect data for 1 second
while (millis() - startMillis < sampleWindow)
{
sample = analogRead(0);
if (sample < 1024) //This is the max of the 10-bit ADC so this loop will include all readings
{
if (sample > signalMax)
{
signalMax = sample; // save just the max levels
}
else if (sample < signalMin)
{
signalMin = sample; // save just the min levels
}
}
}
peakToPeak = signalMax - signalMin; // max - min = peak-peak amplitude
double volts = (peakToPeak * 3.3) / 1024; // convert to volts
Serial.println(volts);
if (volts >=0.5)
{
//turn on FAN
digitalWrite(Wind, HIGH);
delay(1000);
digitalWrite(Wind, LOW);
delay(75);
digitalWrite(Wind, HIGH);
delay(75);
digitalWrite(Wind, LOW);
delay(75);
digitalWrite(Wind, HIGH);
delay(75);
digitalWrite(Wind, LOW);
delay(75);
digitalWrite(Wind, HIGH);
delay(75);
}
else
{
//turn FAN off
digitalWrite(Wind, LOW);
}
}
I suggest playing with the delays so you can finely tune your machine to suit your needs.