Introduction: How to Deal With Noisy Neighbors
Watch the video to see the device in action!
Step 1: Supplies
I used the following items for this device:
1 Arduino Uno
1 5v power source to power the Arduino (I powered it through USB from my laptop)
1 Electret microphone
1 Green 10 LED bar graph (individual LEDs will work too)
1 Red 10 LED bar graph (individual LEDs will work too)
1 Orange LED (or any other color)
1 NPN Transistor 2N3904 or similar
2 0.1uF capacitor
1 100k ohm resistor
2 10k ohm resistor
13 220 ohm resistor (Or whatever will run your LEDs at 5v)
1 CD player
2 Big ol' speakers
I ran out of outputs with the Arduino Uno so my volume meter only uses 2 of the red bars. An Arduino Mega would provide more outputs and make a better volume meter.
Step 2: Setting Up the Circuit
I fed the electret microphone signal through a simple preamp circuit that I found online, then into an analog input on the Arduino. The LEDs are driven directly by the Arduino outputs. To control the music I tapped an output into the play/pause button on my CD player. With my particular CD player the signal needed to be held high at 5V and dropping it down to ground activated the button.
You can download the Fritzing file of the circuit I set up.
Step 3: Programming the Arduino
You can download the attached sketch and load it onto your Arduino. The program will automatically run on powerup.
Some important notes about the code:
const int threshold = 320;
This sets the threshold for triggering the playback. It should be low enough so that the neighbor's music makes our graph go into the red, but high enough so ambient noise won't set it off (like a loud car outside). Play around with this value to set it just right.
These are all of the outputs that make up the LED bar graph. If you use more than I did, you will need to add the extra ports here.
const long waitTime = 10000.0;
This is the 10 second wait period to avoid false alarms. You can change this as needed (the value is in milliseconds).
const long cancelTime = 4000.0;
This is what defines "continuous" music during the waiting period. If the music stays below the threshold for 4 seconds then it cancels the waiting period and goes back to monitoring. You can change this as needed (the value is in milliseconds).
const long playTime = 30000.0;
This is how long the annoying music will be played. It is set for 30 seconds but you can change this as needed (the value is in milliseconds).
This is the CD player control output. With my CD player the play/pause button needed a constant 5V and dropping it to ground would trigger the button. So here I am setting the pin high initially. If your CD player signal needs to be normally low, you can just delete this line.
ledLevel = map(sensorReading, 200, threshold, 0, ledCount);
The 200 here eliminates ambient noise. When it was 0 the first couple LED bars would stay on constantly.
Line 83-85 and 91-93
Again, this is for m y CD player which needed a normally high signal. If your CD player signal needs to be normally low, you need to swap the LOW and HIGH.
Step 4: Installing the Device
Once the circuit is all wired up and the Arduino is programmed, you are pretty much ready to go. I used masking tape to attach the microphone to the wall facing the neighbors. Make sure the CD player is on so that pressing the play button once will start the music.
That's pretty much it! You can leave the system on while you are at home (although your own noise might trigger it), or set it and forget it when you leave.