Introduction: TV Volume Loudness Guard Using Arduino
UPDATES
INTRODUCTION
What can be more annoying than those TV commercials on steroid? Here you are watching your favorite TV show when all of a sudden you are ambushed by a very loud TV commercial sending you scrambling for the remote control to turn down the volume.
In some countries it's now illegal for broadcasters to blast the volume during commercials. But in many others, this TV audio terror is still legal. I hope my TV Volume Loudness Guard will mitigate some of this ad-driven rudeness.
The TV Volume Loudness Guard will listen to your TV and if the volume goes higher than a certain level, it will bring it lower.
There are many uses for this gadget such as keeping the TV volume down when you are in a different room while the kids are watching their favorite music channels. Or when someone blasts the stereo system. The TV Loudness Guard will be ready to keep a lid on it. The TV Loudness Guard should be part of every Big Brother's bag of tricks :)
HOW THIS GADGET WORKS
Place the Arduino TV Volume Loudness Guard close to the TV set to monitor the volume. When the volume loudness of your TV exceeds a certain threshold (set by you in the program or via a trimpot), the gadget sends a Volume Down remote control code to your TV--or any other remote controlled gadget for that matter--until the TV volume falls below the pre-set level. This level can be changed in the program you upload to Arduino or with a potentiometer built into the sound sensor I am using in this project.
WORKFLOW
There are three steps to make use of the TV Volume Loudness Guard:
- Mar 05, 2013 Featured on WonderHowTo http://goo.gl/fpeVC
- Feb 14, 2013 Featured on LifeHacker http://goo.gl/tx4QG
- Feb 13, 2013 I have updated the Arduino program in step 4 to support additional remote controls.
- Feb 13, 2013 Featured on Dangerous Prototypes http://goo.gl/DJcwe
- Feb 12, 2013 Featured on Semageek http://goo.gl/EH58K
- Feb 12, 2013 Featured on Embedds http://goo.gl/Z3egm
- Feb 12, 2013 Featured on Hackaday http://goo.gl/8MkuE
INTRODUCTION
What can be more annoying than those TV commercials on steroid? Here you are watching your favorite TV show when all of a sudden you are ambushed by a very loud TV commercial sending you scrambling for the remote control to turn down the volume.
In some countries it's now illegal for broadcasters to blast the volume during commercials. But in many others, this TV audio terror is still legal. I hope my TV Volume Loudness Guard will mitigate some of this ad-driven rudeness.
The TV Volume Loudness Guard will listen to your TV and if the volume goes higher than a certain level, it will bring it lower.
There are many uses for this gadget such as keeping the TV volume down when you are in a different room while the kids are watching their favorite music channels. Or when someone blasts the stereo system. The TV Loudness Guard will be ready to keep a lid on it. The TV Loudness Guard should be part of every Big Brother's bag of tricks :)
HOW THIS GADGET WORKS
Place the Arduino TV Volume Loudness Guard close to the TV set to monitor the volume. When the volume loudness of your TV exceeds a certain threshold (set by you in the program or via a trimpot), the gadget sends a Volume Down remote control code to your TV--or any other remote controlled gadget for that matter--until the TV volume falls below the pre-set level. This level can be changed in the program you upload to Arduino or with a potentiometer built into the sound sensor I am using in this project.
WORKFLOW
There are three steps to make use of the TV Volume Loudness Guard:
- Capture & decode your remote control Volume Down button (or any other remote function). This feature is included in my gadget.
- Update the TV Loudness Guard program with the remote control button code captured from step 1 and upload the program to your Arduino.
- Power the TV Loudness Guard and place it next to your TV. Fine-tune the parameters of the Arduino program and the sound sensor's potentiometer until you get the desired results.
Step 1: PROJECT PARTS
HARDWARE
SOFTWARE
- GOduino III or Arduino Uno. You should be able to get this project to work with most Arduinos with some tweaking.
- Sound Sensor ($4 from ebay). I used Seeed's sound sensor
- IR 940nm LED Transmitter .($0.10 from ebay)
- IR Receiver 38Khz 3-pin not the 2-pin LEDs. ($1 from ebay) I got mine from Tayda2009.
- 1K Ohms resistor.
- Breadboard.
- Jumper wires.
- Power: you can use USB power or any battery that can source 7V to 12V and over 500mA.
SOFTWARE
- The Arduino IDE (Download from http://arduino.cc/en/Main/Software)
- IRremote library. Download from https://github.com/shirriff/Arduino-IRremote and extract the content of the zip file to folder Arduino\libraries\IRremote
Step 2: WIRING THE TV LOUDNESS GUARD
SOUND SENSOR
- GND pin ---> Arduino GND pin
- VCC pin ---> Arduino 5V pin
- SIG pin ---> Arduino A0 pin
IR TRANSMITTER LED
- Cathode ---> Arduino GND
- Anode ---> 1K Ohms ---> Arduino pin 3 (PWM)
IR 38KHZ RECEIVER (FACING YOU)
- Right Pin ---> Arduino 5V pin
- Middle Pin ---> Arduino GND pin
- Left Pin ---> Arduino 11 pin (PWM)
Step 3: DECODE YOUR REMOTE CONTROL BUTTONS
There are many remote control protocols out there supported by leading vendors such as Sony, NEC, Panasonic, etc. If your TV is not one of those brand named, chances are its remote control adheres to one of the popular remote control protocols supported by the leading vendors.
Since our gadget needs to simulate sending a Volume Down remote control command whenever the TV volume is too high, we need to figure out what's the code for any particular TV remote. This is done easily using the example program provided by the IRremote library.
Since our gadget needs to simulate sending a Volume Down remote control command whenever the TV volume is too high, we need to figure out what's the code for any particular TV remote. This is done easily using the example program provided by the IRremote library.
- With the TV Loudness Guard gadget fully wired, connect your Arduino to your PC.
- From the Arduino IDE, load the example file IRrecvDump which can be found under menu File/Examples/IRremote
- Open the Arduino IDE serial monitor.
- Point your remote control at the IR LED receiver (3 pin) and press the Volume Down button. You will see numbers being displayed on the Serial Monitor.
- Record the short number generated when you pressed your remote button. In my case, the volume down button was 1CE3E817 and the bit count (e.g. 32 bit) which I will see in my Arduino program. You need to replace my remote code with your captured remote control code for your Volume Down button.
Step 4: PREPARE THE ARDUINO PROGRAM
At the top of the Arduino program below there is a number of lines starting with #define LABEL NUMBER This is to make it easier to control how the program behaves. The LABEL is the thing you want to control in the program behavior and the NUMBER is the value of the thing you want to control. Here's an explanation of the relevant #define lines.
REMOTE BUTTON CODE & BIT
#define REMOTE_CODE Your remote code as returned by the IRrecvDump decoder utility prefixed with "0x"
#define REMOTE_BIT Your remote code data size as returned by the IRrecvDump decoder utility.
This Arduino program works for most remote controls but you need to tell it about your remote control protocol from the info you gathered in the previous step when you decoded your remote control buttons using IRrecvDump utility. It's possible to make the remote selection dynamic during run time so you don't have to change and upload code. I might do this in a later version of this gadget.
VOLUME LEVEL THRESHOLD
#define NOISE_LEVEL A number from 0 to 1024. Start with 500 then fine-tune the number.
This is the number that decides at what point the Arduino will start transmitting Volume Down codes
NOTE: The sound sensor I am using as a built-in potentiometer which also controls the sensor's sensitivity.
VOLUME CHANGE SPEED
#define REPEAT_TX (from 1 to as many as you want. Start with 3 then fine tune)
Change how many times you want the remote code transmitted to the TV. If you want more drastic drop in TV volume increase this number. If you want a more gradual change in volume, lower this number.
FEATURE TODO LIST
It's very simple to program more functionality into this gadget. Some of the features that can be added:
THE ARDUINO CODE
Cut and paste the code below into your Arduino IDE
//=================================================
/*
PROJECT: TV Volume Guard
AUTHOR: Hazim Bitar (techbitar)
DATE: FEB 9, 2013
CONTACT: techbitar at gmail dot com
LICENSE: My code is in the public domain.
IRremote library: copyright by Ken Shirriff http://arcfn.com
*/
#include <IRremote.h>
#define NOISE_LEVEL 350 // level of noise to detect from 0 to 1023
#define REPEAT_TX 3 // how many times to transmit the IR remote code
#define REMOTE_CODE 0x1CE3E817 // remote code to transmit. This is for my TV. Replace with yours.
#define REMOTE_BIT 32
#define SOUND_SENSOR_PIN A0 // sound sensor connected to this analog pin
#define LED 13 // LED used to blink when volume too high
IRsend irsend; // instantiate IR object
void setup()
{
pinMode(LED, OUTPUT);
}
void loop()
{
int soundLevel = analogRead(SOUND_SENSOR_PIN); // read the sound sensor
if(soundLevel > NOISE_LEVEL) // compare to noise level threshold you decide
{
digitalWrite(LED,HIGH); // LED on
delay(200);
for (int txCount = 0; txCount < REPEAT_TX; txCount++) { // how many times to transmit the IR remote code
irsend.sendNEC(REMOTE_CODE , REMOTE_BIT); // Change to match your remote protocol
delay(200);
// Uncomment the function that matches your remote control protocol as shown by IRrecvDump
// irsend.sendNEC(REMOTE_CODE, REMOTE_BIT);
// irsend.sendSony(REMOTE_CODE, REMOTE_BIT);
// irsend.sendRC5(REMOTE_CODE, REMOTE_BIT);
// irsend.sendRC6(REMOTE_CODE, REMOTE_BIT);
}
}
digitalWrite(LED,LOW); // LED off
}
//=================================================
REMOTE BUTTON CODE & BIT
#define REMOTE_CODE Your remote code as returned by the IRrecvDump decoder utility prefixed with "0x"
#define REMOTE_BIT Your remote code data size as returned by the IRrecvDump decoder utility.
This Arduino program works for most remote controls but you need to tell it about your remote control protocol from the info you gathered in the previous step when you decoded your remote control buttons using IRrecvDump utility. It's possible to make the remote selection dynamic during run time so you don't have to change and upload code. I might do this in a later version of this gadget.
VOLUME LEVEL THRESHOLD
#define NOISE_LEVEL A number from 0 to 1024. Start with 500 then fine-tune the number.
This is the number that decides at what point the Arduino will start transmitting Volume Down codes
NOTE: The sound sensor I am using as a built-in potentiometer which also controls the sensor's sensitivity.
VOLUME CHANGE SPEED
#define REPEAT_TX (from 1 to as many as you want. Start with 3 then fine tune)
Change how many times you want the remote code transmitted to the TV. If you want more drastic drop in TV volume increase this number. If you want a more gradual change in volume, lower this number.
FEATURE TODO LIST
It's very simple to program more functionality into this gadget. Some of the features that can be added:
- Average audio level over a period of time to determine if increase in volume is persistent requiring volume control or momentary and should be ignored.
- Read audio level after a period of time. If audio is too low, increase volume by a certain increment.
- Make program inclusive of supported remote protocols
- Add Panasonic & JVC support
THE ARDUINO CODE
Cut and paste the code below into your Arduino IDE
//=================================================
/*
PROJECT: TV Volume Guard
AUTHOR: Hazim Bitar (techbitar)
DATE: FEB 9, 2013
CONTACT: techbitar at gmail dot com
LICENSE: My code is in the public domain.
IRremote library: copyright by Ken Shirriff http://arcfn.com
*/
#include <IRremote.h>
#define NOISE_LEVEL 350 // level of noise to detect from 0 to 1023
#define REPEAT_TX 3 // how many times to transmit the IR remote code
#define REMOTE_CODE 0x1CE3E817 // remote code to transmit. This is for my TV. Replace with yours.
#define REMOTE_BIT 32
#define SOUND_SENSOR_PIN A0 // sound sensor connected to this analog pin
#define LED 13 // LED used to blink when volume too high
IRsend irsend; // instantiate IR object
void setup()
{
pinMode(LED, OUTPUT);
}
void loop()
{
int soundLevel = analogRead(SOUND_SENSOR_PIN); // read the sound sensor
if(soundLevel > NOISE_LEVEL) // compare to noise level threshold you decide
{
digitalWrite(LED,HIGH); // LED on
delay(200);
for (int txCount = 0; txCount < REPEAT_TX; txCount++) { // how many times to transmit the IR remote code
irsend.sendNEC(REMOTE_CODE , REMOTE_BIT); // Change to match your remote protocol
delay(200);
// Uncomment the function that matches your remote control protocol as shown by IRrecvDump
// irsend.sendNEC(REMOTE_CODE, REMOTE_BIT);
// irsend.sendSony(REMOTE_CODE, REMOTE_BIT);
// irsend.sendRC5(REMOTE_CODE, REMOTE_BIT);
// irsend.sendRC6(REMOTE_CODE, REMOTE_BIT);
}
}
digitalWrite(LED,LOW); // LED off
}
//=================================================
1 Person Made This Project!
- james.heires made it!
31 Comments
Question 2 years ago on Step 2
For the Sony TV remote, I get a volume down remote code of C90. For the cable box remote the volume down code is 640C. If I try to compile with either of these codes with the REMOTE_BIT set properly I get a compile error: 'C90' or 'C' was not declared in this scope.
Is it necessary to put 0x in front of the remote code? It will compile when I do, but the project won't lower the volume. The mic is working and the noise level has been set at different points in several trials. What am I doing wrong?
7 years ago
OK - I am reading my cable box remote volume down codes, but each sample is completely different from the prior (see below for my serial window output after pushing the down volume 5 times). Is there some kind of pseudo-random code sequence? Also, when you say to "Record the short number generated when you pressed your remote button." Do you mean the row of numbers with the fewest numbers? Because when I press volume down on my remote, I get only one group of 3 rows of numbers.
Your help would be appreciated, as I wish to get this working.
944C8D98
Unknown encoding: 944C8D98 (32 bits)
Raw (22): 300 -650 350 -1700 300 -650 350 -950 150 -1550 300 -1200 300 -1150 350 -1000 350 -1000 100 -1450 300
A974063A
Unknown encoding: A974063A (32 bits)
Raw (18): 350 -600 350 -1700 300 -650 300 -2700 300 -1200 300 -1100 400 -1000 350 -2550 300
1DD876BC
Unknown encoding: 1DD876BC (32 bits)
Raw (18): 300 -650 300 -1750 300 -650 300 -2700 300 -1200 250 -1250 300 -950 400 -2550 300
8771921F
Unknown encoding: 8771921F (32 bits)
Raw (18): 300 -650 300 -1750 250 -700 300 -2650 350 -1150 300 -1000 450 -1150 300 -2550 250
D4185E7E
Unknown encoding: D4185E7E (32 bits)
Raw (20): 300 -650 350 -950 150 -600 300 -650 300 -2700 300 -1200 300 -1200 250 -1050 350 -2550 300
Reply 7 years ago
Just getting back to this, and had another idea on remote codes, since it seems as if Mediacom is scrambling their remote codes (see post above). I have switched to using my TV's own remote (not the Mediacom cable box's remote) to control volume.
Reply 3 years ago
Did you get an answer on this? I have an RCA TV and Im getting similar results when trying to get the codes. Any help would be greatly appreciated!
4 years ago
I have done it also and just want to thank you for your effort. It's working but needs some tuning.
8 years ago on Introduction
When I experience annoying loud television advertisements, I send an email to the advertiser that I am boycotting their products. If enough people do the same, the practice will stop.
Reply 5 years ago
+1
7 years ago
Done it. Thanks
9 years ago on Introduction
Very cool :) How hard would it be to have it keep the volume at a certain level turn the tv down for the commericials and then back up when the quieter show comes back on.
Reply 9 years ago on Introduction
I would love something like this too. It's not just commercials, but sometimes movies go from whisper quiet to explosion loud and I'd love a device that just kept the TV at a certain range, automatically raising the volume up and down as needed.
Reply 8 years ago on Introduction
I'm doing this but I'm having trouble with the code. the IDE will not compile it, due to countless errors. anyone else have trouble, or understand the code in depth?
Reply 7 years ago
Hopefully you solved your compilation error problems by now, but I initially had some issues too, because of multiple IRremote.h files in my Arduino library search path. I removed the offending library and it now compiles OK.
8 years ago on Introduction
This is too complicated for little ole me and I was wondering, are there any tv's that control the volume without extra equipment?
Missy
gaynel13@gmail.com
Reply 7 years ago
Missy, See my reply to nancy.lowery above for two such models.
7 years ago on Introduction
I wish I could just go buy something like this. My father-in-law lives with our family and he is hard of hearing so he puts the volume so loud I have headaches every day. He refuses to turn it down, he has already blown speakers on one of our TV's. I do not know how to control his behavior.
Reply 7 years ago
There is at least one commercial product that I found while researching this topic. It is branded with either Terk or Audiovox. I found the Audiovox unit on ebay just now (http://www.ebay.com/itm/NEW-IN-BOX-Audiovox-VR1-Au...) and the Terk at (http://www.ebay.com/itm/TERK-BY-AUDIOVOX-TV-VOLUME-REGULATOR-STOPS-LOUD-COMMERCIALS-TV-VOLUME-CHANGES-/281841526306?hash=item419f106622:g:FXMAAOSw14xWMP2x). According to review online, the Terk is a better quality product. Neither of these requires programming or IR learning, etc. Just needs to be connected between the audio source (e.g., cable box) and the TV.
Good luck.
7 years ago
Great job.
7 years ago on Introduction
What level of volume (Sound) should I set in my Sony LED TV and Tata Sky set top box? Maximum TV volume is 100 points and maximum set top box volume is 20 points. How much should I set both the volumes so that I get optimum audible sound?
8 years ago on Introduction
big respect for u
8 years ago on Introduction
you didn't include "IRromote.h" and while i have it, the code has presented some problems in my IDE, did you change it from the IR library online?