Project tutorial
Turn On/Off TV Sound System Using the TV IR Remote Control

Turn On/Off TV Sound System Using the TV IR Remote Control © GPL3+

How to control a PC sound system connected to a TV using the IR remote control power button, so both TV & sound system are on/off together.

  • 523 views
  • 1 comment
  • 4 respects

Components and supplies

Apps and online services

About this project

The idea behind this project was, I must admit it, to be lazy!

My current TV setup is a bit cheap, but you know, it works just fine:

  • A LCD TV
  • A 2.1 computer sound system (with wired power and volume command)

So each time I want to watch the TV, I need to go to the TV, use the wired command (that I put just next to the TV) to switch the audio on, then go back to my couch and use the TV remote to switch the TV on...

As there is few meters between the TV and the couch, it's OK, but you know sometimes I just would like to be able to power on both TV and sound system just using the TV remote.

Components

The project

Well it's simple: use the TV remote control to switch on the audio system. To make it easier, I want that the power button of the remote turn on both TV and audio system at the same time.

For that I need an IR receiver module to be able to decode the signal sent while pressing the remote power button.

I also need to be able to switch on/off the sound system. Looking in the sound system wired command, I saw it has an on/off button. By soldering a wire on each terminals of this switch I can open/close the circuit using a relay module.

What I noticed is that the sound system was OFF when the switch was opened and was ON when the switch was closed. Hopefully, SRD-05VDC-SL-C relay wiring allows to have the circuit opened or closed when relay is not powered. That's the second solution that I want to use: if the Arduino is not powered, the sound system is off by default (just use an ohmmeter on the relay outputs to chose the right ones).

Finally I need an Arduino to read the IR code sent by the TV remote and drive the relay to turn on/off the audio. At first I did a dummy program that just prints the power button code from the IR receiver module to the serial output, and then did the final one to open/close the relay if this specific code is received.

Once done, each time I push the power button of the TV remote control, both TV and audio system are ON (I've located the IR receiver close to the one of the TV, so they should both receive the same remote signal.). If I push the button again they are both turned off.

One issue I faced, is that sometime, one of the IR receiver does not catch properly the remote signal and so you have the TV ON with no sound, or the sound ON but the TV switched off.

To fix de-synchronization issues, I've allowed a second button from the remote to control the relay of the sound system so I can control it independently to synchronize back the two equipments.

And... that's it ! It's simple, and it works fine.

Code

Control a relay using an IR receiver with an Arduino NanoArduino
#include <IRremote.h>
#include <IRremoteInt.h>
//#include <stdio.h>

#define RELAY_OUT 5
#define IR_RECV 3

// Default relay LOW
int level = LOW;

unsigned int timeout = 0;

// Declare IR objects
IRrecv irrecv(IR_RECV);
decode_results results;

void setup() {
 // Initialize digital pin 5 as an output for relay control
 pinMode(RELAY_OUT, OUTPUT);
 // Turn the relay off to start (switch off sound system)
 digitalWrite(RELAY_OUT, level);

 // Setup serial
 //Serial.begin(9600);

 // Enable IR receiver
 irrecv.enableIRIn();
}

// The main loop will continue to run until the arduino loses power
void loop() {

 // Read IR receiver
 if(irrecv.decode(&results))
 {

  //char value[25] = "";
  //sprintf(value, "Pressed button: %d\n", results.value);
  //Serial.println(value);
   
  // If IR output matches the POWER or RED buttons
  // values should be updated with the one of your remote control
  if(results.value == 50153655 || results.value == 50139885)
  {
   //Serial.print("New level is: ");
  
   // Switch relay on/off
   if(level == LOW)
   {
    level = HIGH;
   }
   else if(level == HIGH)
   {
    level = LOW;
   }
   
   //Serial.println(level);
   
   // Update relay level
   digitalWrite(RELAY_OUT, level);
   timeout = 0;
  }

  // Receive the next value
  irrecv.resume(); 
 }

 // Wait for 500ms before reading next value
 delay(500);
 
 timeout += 1;

 // Automatic shutdown after 4h
 if(timeout >= 28800)
 {
  timeout = 0;
  level = LOW;
  digitalWrite(RELAY_OUT, level);
 }
}

Schematics

Infrared controlled relay with Arduino Nano
Ir relay sketch 90cflzi5xx
Mounted on PCB kit
1 ytqzayjbif
Done !
5 4oppsyslkb

Comments

Similar projects you might like

IR Remote Controlled Power Switch for Rapsberry Pi 3

Project tutorial by Vilém Kužel

  • 1,085 views
  • 1 comment
  • 5 respects

Arduino: Switching ON/OFF Appliances Using IR Remote

Project showcase by Naman Chauhan

  • 11,156 views
  • 0 comments
  • 126 respects

Arduino TV Volume Control

Project tutorial by Sam

  • 6,184 views
  • 1 comment
  • 15 respects

WiFi IR Blaster

Project tutorial by BuddyC

  • 90,305 views
  • 43 comments
  • 96 respects

Developing an IR Remote and Software Controller

Project tutorial by Steve

  • 18,620 views
  • 0 comments
  • 38 respects
Add projectSign up / Login