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. 


#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.


#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. 


#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.


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


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
    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

      // 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

Great job.
<p>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?</p>
<p>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. </p>
<p>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.</p>
<p>This is too complicated for little ole me and I was wondering, are there any tv's that control the volume without extra equipment?</p><p>Missy <br>gaynel13@gmail.com</p>
<p>big respect for u </p>
<p>you didn't include &quot;IRromote.h&quot; and while i have it, the code has presented some problems in my IDE, did you change it from the IR library online?</p>
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.
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.
<p>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?</p>
It seems i'm only one who can't make it work. <br> <br>Noise level == 45 <br> <br>Blinking led on pin 13 tells that microphone is working. <br> <br>But IR led on pin3 is not blink (it visible with any mobile camera). If i reconnect IR LED to pin13 - it blinks. <br>IF i connect any other LED to pin 3 ---&gt; no blinking too <br>If i load those simple example that make onboard LED blinks and set the pin 3 - IR LED start blink. <br> <br>What's wrong? <br> <br>Arduino Mega 2560
I had the same problem and found the solution in the source code of the IRremote library: on the ATmega2560 the IR diode must be connected to pin 9, see https://github.com/shirriff/Arduino-IRremote/blob/master/IRremoteInt.h
Nice! <br>This could be used on pubs, restaurants, and the like! <br>Gone to my Blog: <br>3D Printers from India, Nano-printing 3D printers, and an Arduino that shuts up TV ads! http://faz-voce-mesmo.blogspot.pt/2013/02/impressoras-3d-uma-da-india-outra-nano.html
Glad you like it. It's more challenging in public places because of the ambient noise. But it's not difficult to read the audio signal directly from the headphone jack instead of an open mic. This could be Rev2 of the gadget.
Go for it, but don't forget to Patent it, because I see all kinda crazy stuff being sold, that's not useful as that one idea...
This project is based on all sorts of open source and open hardware ideas so it's only fair that it remains open :)
Right you are, but if someone makes money out of manufacturing those, isn't there somewhere, some open source support thing, you can send some kind of royalties?
Great project! Everybody should have one before they totally get brainwashed...I wanted something like this for decades! There were some devices many years ago to zero the volume when advertisements start but some marketing lobby stopped them to sell or built in to the TVs. Now I have to congratulate you...for me it is too late, I don't have TV for years now, because of the ads.
Merci! I think dumping the TV is the ideal solution. The internet is enough nowadays.
Excellent project. I need one of these. :D
Thanks! If you build one please share your experience. The Arduino program can benefit from more intelligence with additional timing parameters. I might update it in an upcoming version.

About This Instructable


119 favorites


Bio: Did I unplug the solder iron?
More by techbitar: IR Remote Control Station for Android - TURN THE TV DOWN SensoDuino: Turn Your Android Phone into a Wireless Sensors Hub for Arduino Modify The HC-05 Bluetooth Module Defaults Using AT Commands
Add instructable to: