IR Advert Killer

Television Advertisements can be hard to ignore and totally irritating when you have heard and seen the same thing for the umpteenth time.  I wanted to manually kill the audio only for the duration of the advert break on my Satellite Box with timed infra red signals to the box’s mute option and have an auto resume program.  However my Satellite Box has a complicated IR Protocol (I wonder why now?), and it finally dawned on me that I could just mute the television and use it on that system too.

I first thought about printing my own IR remote control complete with timing electronics to send the mute signal and then after a pre-determined time say 3 minutes, it would re-send the mute signal to return the audio to normal.

Increasing the number of IR remotes around a lounge room is really annoying too! So I hit on the idea of intercepting a number of “unused” buttons on the TV remote (Sony Bravia) to control the Arduino system, and then have the system relay-transmit the  timed muting signals.  The Sony Bravia remote has 4 coloured buttons that normally don’t do anything, Red, Green, Yellow and Blue.  These were allocated muting times of Red=120sec, Green=150sec, Yellow=180sec and Blue=210sec. This would allow a muting period to be selected depending on channel or time of day, and therefore, no extra remote. These times can be customised easily to fit with the “content” you most want to mute.

IR_remote_01

To achieve this aim I relied very heavily on the routines by Ken Shirriff (IR Library) as I needed to be able to decode the Sony protocol, and also to imitate it as well.

advertkiller

I also added an RGB status LED to glow in the same colour as the selected button, and flash to indicate the muting was in action.

The system does not require much hardware:

  • Arduino Pro-Mini (though nearly any Arduino will work)
  • IR Emitting LED (take revenge on an old remote)
  • IR Detector (IR1261 is suggested)
  • RGB LED (common Anode is suggested)
  • 3 of 470ohm resistors
  • Breadboard and connectors
  • A serial interface will also be required to program the Arduino Pro-Mini from a standard USB and the IDE

The program is below.  Copy and paste it into an Arduino IDE and download to your target CPU.

/* An Advertisement sound Killer!!!
 * Developed for a Sony TV but can be adapted to others
 * Author: Rob Ward http://www.laketyersbeach.net.au
 * An IR LED *must* be connected to Arduino PWM pin 3, via a 470ohm resistor to GND.
 * Version 1.0 25/09/2017
 * Developed using work from the...
 * IR Library Copyright 2009 Ken Shirriff
 * http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
 * This source provides the IR library and other routines that can be used
 * to discover the remote controls for muting other brands of Televisions.
 */

int IR_Rx = 2; //IR Receiver
int IR_Tx = 3; //IR Transmitter (cathode to ground)
//RGB LED in this case is Common Anode
int redLED = 4; //Red LED
int bluLED = 5; //Green LED
int greLED = 6; //Blue LED
int maskLED = 7; //mask for active LEDs 7 = all on 
int ledPin = 13; //Shows duration is active
int advert = 390; //Delay of the Advert Break in seconds eg 390

/*
Sony IR Remote Controls
 Mute 0x290,12
 Red 0x338,12
 Green 0xB38,12
 Yellow 0x738,12
 Blue 0xF38,12
 */

#include <IRremote.h>
IRsend irsend; //uses Pin 3 (PWM essential)to drive the IR LED
IRrecv irrecv(IR_Rx); //using Pin 2 works for IR reception
decode_results results;

void setup(){
 pinMode(redLED, OUTPUT); 
 pinMode(bluLED, OUTPUT);
 pinMode(greLED, OUTPUT);
 //The RGB LED is common Anode, so inverse logic required
 digitalWrite(redLED,1); //make sure it is off
 digitalWrite(bluLED,1); //make sure it is off
 digitalWrite(greLED,1); //make sure it is off
 pinMode(ledPin, OUTPUT);
 irrecv.enableIRIn(); // Start the receiver
 Serial.begin(115200);
 delay(100);
 //Serial.println("Listening...");
}

void loop(){
 //Wait for a button press
 if (irrecv.decode(&results)) {
 //Serial.print(results.value, HEX);
 if(results.value == 0x338){
 //Serial.println(" Red...");
 mute(120,1); //2 minutes, red=1
 }
 if(results.value == 0xB38){
 //Serial.println(" Green...");
 mute(150, 2); //2.5 minutes, green=2
 }
 if(results.value == 0x738){
 //Serial.println(" Yellow...");
 mute(180,3); //3 minutes, red+green=yellow=3
 }
 if(results.value == 0xF38){
 //Serial.println(" Blue...");
 mute(210,4); //3.5 minutes, blue=4
 }
 irrecv.resume(); // Receive the next value
 //Serial.println("Finished...");
 irrecv.enableIRIn(); // Re-start the receiver
 }
}

void mute(int advert, int mask){
 digitalWrite(ledPin,HIGH); //toggle onboard LED
 delay(1000); //separate receive from send IR
 IRsend irsend;
 //Serial.print("Mute Start<");
 sendIR(); //Send the mute signal on
 for (int j=0;j<advert;j++){
 delay(500);
 //Serial.print(".");
 if(mask & 1){
 digitalWrite(redLED,0);//turn on Red LED
 }
 if(mask & 2){
 digitalWrite(greLED,0);//turn on Green LED
 }
 if(mask & 4){
 digitalWrite(bluLED,0);//turn on Blue LED
 }
 delay(500);
 digitalWrite(redLED,1); //make sure it is off
 digitalWrite(greLED,1); //make sure it is off
 digitalWrite(bluLED,1); //make sure it is off
 }
 digitalWrite(ledPin,0); //make sure it is off
 sendIR();//Send the mute signal off
 //Serial.println("> Mute End");
}

void sendIR(){
 //send code 3 times quickly for Sony Protocol
 for (int i = 0; i < 3; i++) {
 irsend.sendSony(0x290,12); // Sony Mute code
 delay(30); //timing critical, can't be too long or short
 }
}

// Mini-Pro PinOut TopView
// R
// e
// G s R T
// D e x x
//9 8 7 6 5 4 3 2 N t D D
//^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
//
//
//v v v v v v v v v v v v
//1 1 1 1 A A A A V R G R
//0 1 2 3 0 1 2 3 c e N A
// c s D W
// e
// t

Obviously if you do not own a Sony Bravia then this system will almost certainly not work straight off the page.  However Ken Shirrif’s pages on IR remotes will give you routines to discover the codes on your system for mute, and the coloured buttons on your TV remote. You can use the present system as shown in the wiring diagram above (thanks Fritzing).  The timing between receiving the “coloured button” signal from the remote and then sending the muting signal can be critical, as it appears the system requires some time to stabilise between IR bursts. So don’t expect split second responses.

As for the 3-D printing, I thought I could make a little box to attach it to the bottom of the TV unobtrusively near the TV’s IR sensor and power it from the TV’s USB socket.

Once you are armed with the codes for your TV you should be able to adapt the Arduino program to your needs.  You will be able to mute the advertisement, go and make a cuppa, and know the sound will come back on without having to rush over pick the remote and un-mute it!!! The code is short and could be adapted to channel hopping during the muted time etc Luxury!!!

Best Wishes, Rob

 

 

 

 

 

 

 

 

 

 

 

 

 

 


 

Advertisements

11 thoughts on “IR Advert Killer

  1. Apologies to all those people who thought this might be a sophisticated AI solution. It is after all just a “hack” on the manual IR remote buttons. Not a total design for avoiding the adverts, so submitting to Hack-a-Day seemed appropriate for me. Cheers.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s