Introduction: Mute Your TV for the Duration of the Commercials

If like me your fed up listening to the same commercials time and time again so mute the sound, but often miss the restart of the programme.

CAUTION; since making this I have noticed that it reliably works at times under 30 sec, but when extended to minutes it can fail to restore audio, I'm looking into a better way of counting the 3 minute delay.
But for now you add a series delays each of 30 seconds to make up to the total time you want between mute and restore.
Arduino appears to have a problem using the delay command when the delay is over 35 seconds.

Using Arduino uno you can build a mute timer that restores the audio after a set time.

A future development could be to make it store the code from any TV Remote by adding a record function, at this time thats 
beyond my skill level, so if anyone wants to add to this I would be delighted.

The only thing I can claim as mine is the idea, the code has been copied and hacked from various sites and projects.

You require an Arduino
an IR sender
an IR receiver
a push switch, to start the code, its not a locking switch just a single press and release
a breadboard to hold your components while you experiment,
They only cost a few pounds so its a very inexpensive project. I will add images of the final unit once I build it into a box but for now here is the code and links to sources I used.

Once you build the components first load up the IR Reader software to capture the mute signal from your remote.
Then load up the TV Mute sketch and change the mute values to those that your TV requires.

I used the information and cod from these sites to design my project.

https://www.instructables.com/id/How-to-control-your-TV-with-an-Arduino/

http://www.learn.adafruit.com/ir-sensor/making-an-intervalometer/

http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html


Here's a tip, if you want to see an IR LED emit its signal look at the LED using the screen on your digital camera  while pressing the button, most cameras can see IR, but don't use an Iphone, they have an IR filter that blocks IR so it will not see the signal



Connect IR receiver to pins 11, Gnd, and 5v ,

You will note that the sensors are connected to different pins in some images, the connections are dependant on the software sketch you have loaded so take note each time you load up a sketch, in the code there will be comments that state where the sensors are connected.

Connect the IR sender to Pins 12 and Gnd.  
Connect the start switch to pin 3 and Gnd.
My attempts to attach the Arduino sketch here failed, so here is the code for the Mute sketch, copy and paste it into the Arduino window .


The timing function has been refined, please see the newer version of the code below.
The new lines are 

unsigned long timespan = 180000;
delay (timespan);  // wait 3 minutes
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


// This sketch will send out a Sony Mute signal
// Information and original code from http://learn.adafruit.com/ir-sensor  and https://www.instructables.com/id/How-to-control-your-TV-with-an-Arduino/
// Information and original code from http://learn.adafruit.com/ir-sensor/making-an-intervalometer
// Credit to Ian Lang who helped me solve my timing issue.
// this code is public domain, please enjoy!

int IRledPin =  12;    // LED connected to digital pin 12
int buttonPin = 3;     // footswitch connected to digital #3 Ground the pin to initiate

// The setup() method runs once, when the sketch starts
unsigned long timespan = 180000;
void setup()   {               
  // initialize the IR digital pin as an output:
  pinMode(IRledPin, OUTPUT);     
 
  pinMode(buttonPin, INPUT);
  digitalWrite(buttonPin, HIGH); // pullup on
 
  Serial.begin(9600);
}
// initially set your delay at 10 seconds to test the operation, then change it to 1800 for a full 3 minutes mute, or a bit shorter
// to allow the time it takes you to initiate the mute and to catch the very end off the commercials .
void loop()                    
{
  if (! digitalRead(buttonPin))
  {
    Serial.println("Sending IR signal"); // muteswitch pressed
    SendCMuteCode();
    delay (timespan);  // wait 3 Minutes
    Serial.println("Sending IR signal2");
    SendCMuteCode();
  }
}

// This procedure sends a 38KHz pulse to the IRledPin
// for a certain # of microseconds. We'll use this whenever we need to send codes
void pulseIR(long microsecs) {
  // we'll count down from the number of microseconds we are told to wait
 
  cli();  // this turns off any background interrupts
 
  while (microsecs > 0) {
    // 38 kHz is about 13 microseconds high and 13 microseconds low
   digitalWrite(IRledPin, HIGH);  // this takes about 3 microseconds to happen
   delayMicroseconds(10);         // hang out for 10 microseconds
   digitalWrite(IRledPin, LOW);   // this also takes about 3 microseconds
   delayMicroseconds(10);         // hang out for 10 microseconds

   // so 26 microseconds altogether
   microsecs -= 26;
  }
 
  sei();  // this turns them back on
}

void SendCMuteCode() {
  // This is the code for my particular Canon, for others use the tutorial
  // to 'grab' the proper code from the remote
 
  delayMicroseconds(2595);
  pulseIR(2450);
  delayMicroseconds(600);
  pulseIR(600);
  delayMicroseconds(600);
  pulseIR(600);
  delayMicroseconds(600);
  pulseIR(1200);
  delayMicroseconds(600);
  pulseIR(600);
  delayMicroseconds(600);
  pulseIR(1250);
  delayMicroseconds(600);
  pulseIR(600);
  delayMicroseconds(600);
  pulseIR(650);
  delayMicroseconds(600);
  pulseIR(1200);
  delayMicroseconds(600);
  pulseIR(600);
  delayMicroseconds(600);
  pulseIR(600);
  delayMicroseconds(600);
  pulseIR(650);
  delayMicroseconds(600);
  pulseIR(650);

   
  delay(65); // wait 65 milliseconds before sending it again
 
   delayMicroseconds(2595);
  pulseIR(2450);
  delayMicroseconds(600);
  pulseIR(600);
  delayMicroseconds(600);
  pulseIR(600);
  delayMicroseconds(600);
  pulseIR(1200);
  delayMicroseconds(600);
  pulseIR(600);
  delayMicroseconds(600);
  pulseIR(1250);
  delayMicroseconds(600);
  pulseIR(600);
  delayMicroseconds(600);
  pulseIR(650);
  delayMicroseconds(600);
  pulseIR(1200);
  delayMicroseconds(600);
  pulseIR(600);
  delayMicroseconds(600);
  pulseIR(600);
  delayMicroseconds(600);
  pulseIR(650);
  delayMicroseconds(600);
  pulseIR(650);
}
Arduino Contest

Participated in the
Arduino Contest