Control Your Tv, Dvd and Audio System With Arduino and Android





Introduction: Control Your Tv, Dvd and Audio System With Arduino and Android

About: My name is José Luis Bejarano Vásquez.Tecnólogo en electrónica, estudiante de ing electrónica, desarrollador de software. Aficionado a la robótica. Blogger.

Hi everybody, this is my second instructable and my first in English, so, sorry for the mistakes.

I want to share this project it's about how you can control your Tv, DVD and your Audio System with Arduino and an app for Android made with app inventor.

If you like this project, please vote for it in the Home automamtion contest.

It is divived in two parts, the first it is for obtaining the codes of the remote control, and the second it is the real project of controlling the devices.

General Part List:

  • (1) Arduino One.
  • (1) Breadboard.
  • (1) Ir Receiver Tsop1838 or equivalent.(for capturing the codes, No used in the project of controlling).
  • (2) IR Leds
  • (1) HC-05 Bluetooth module.
  • (2) 220 ohm resistors.
  • Jumper cables.
  • (1) Remote control.

    (for capturing the codes, No used in the project of controlling).

  • Note: the youtube video has english subtitles.

Step 1: Obtain the Codes for Buttons (I)

First, we must to obtain the codes for every button of our remote control.

So, build the circuit on the breadboard like shown on figure.

The Ir receiver TSOP 1738 has three pins.

The first is the output, connected to pin 11 in Arduino.

The second goes to Gnd, and the third it is connected to +5V.

Download the IrRemote library writen by Ken Shirriff. This library let us both send and receive Ir remote codes in multiple protocols like Nec, Philips RC5, Philips RC6 and raw.

we have to connect an infrared sensor like the osp1738 to any digital input pin.

Download from here the sketch

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup() {


irrecv.enableIRIn(); // Start the receiver


// Dumps out the decode_results structure.

// Call this after IRrecv::decode()

// void * to work around compiler issue

//void dump(void *v)

{ // decode_results *results = (decode_results *)v

void dump(decode_results *results)

{ int count = results->rawlen;

if (results->decode_type == UNKNOWN)

{ Serial.print("Unknown encoding: ");


else if (results->decode_type == NEC)

{ Serial.print("Decoded NEC: ");

} else if (results->decode_type == SONY)

{ Serial.print("Decoded SONY: ");


else if (results->decode_type == RC5)

{ Serial.print("Decoded RC5: "); }

else if (results->decode_type == RC6)

{ Serial.print("Decoded RC6: "); }

else if (results->decode_type == PANASONIC)

{ Serial.print("Decoded PANASONIC – Address: ");


Serial.print(" Value: "); }

else if (results->decode_type == JVC)

{ Serial.print("Decoded JVC: "); }

Serial.print(results->value, HEX);

Serial.print(" (");

Serial.print(results->bits, DEC);

Serial.println(" bits)");

Serial.print("Raw (");

Serial.print(count, DEC);

Serial.print("): ");

for (int i = 0; i < count; i++)

{ if ((i % 2) == 1)

{ Serial.print(results->rawbuf[i]*USECPERTICK, DEC); }


{ Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC); }

Serial.print(" "); }

Serial.println(""); }

void loop()


if (irrecv.decode(&results))


Serial.println(results.value, HEX);


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



Step 2: Obtain the Codes (II)

After you have built the circuit for capturing the codes, open the serial monitor on the Arduino Ide, press the desired button in the remote control and see which values the arduino is receiving, like is shown in the image. Arduino will receive the protocol, the code and the raw codes.

For example. those are the codes when i pressed the power and the open/close buttons of my dvd player remote control.

Save or copy the codes received for every desired button that you will use for controlling the devices.

In my skethch i used for Tv: power, volume+, volume-, channel + and channel - and TV/Dvd buttons.

For dvd, power, open/close, play and stop.

For audio system i only want to control the power, play cd and presets buttons.

These codes will be used on the next sketch.

Step 3: Diagram Circuit

As you can see, we need only:

  • Arduino board.
  • Bluetooth module HC-05.
  • Infrared led's. (I have used two for the disposition of my tv, dvd and the stereo, the number of infrared leds depends of the disposition of your devices).

Note: the infrared led has to be connected to arduino pin # 3. That's because the library is setup that way.

Only three pins of the Arduino are used:


3 - To Led's

0 - BT module pin Tx

1 - BT module pin Rx

Remember that when you upload the sketch to the Arduino, the bluetooth module has to be disconnected.

Step 4: The Code in Arduino

Clic here for downloading the code or copy the following lines:

#include "<\IrRemote.h\>";

IRsend ir;

int estado=0;

char dato;

//These codes are for controlling the Audio System

unsigned int powerEquipo[32]={300,750,300,1800,300,700,350,700,350,1750,350,700,300,1800,250,1800,350,700,300,1800,350,700,300,700,350,700,350,1750,300,750,300}; //unsigned int chEmisoraUp[32]= {300,750,300,750,300,1750,250,800,300,750,300,750,250,800,300,750,250,1800,250,1850,300,750,250,800,200,800,300,1800,300,750,300}; unsigned int chEmisoraUp[32] ={300,750,300,750,300,1800,200,850,300,750,250,750,300,750,300,750,300,1800,300,1750,300,750,300,750,300,750,300,1800,250,750,300}; unsigned int chEmisoraDown[32] = {350,700,400,650,300,1750,350,700,350,700,350,700,300,750,300,700,350,700,300,750,350,1750,400,650,300,700,350,1750,300,750,300};

unsigned int playCd[32] = {400,650,400,650,350,1750,350,700,350,650,350,1750,350,1750,300,1750,400,1700,350,1750,350,700,350,650,400,650,350,1750,450,600,350};

//These codes are for controlling the Tv

unsigned int pwrTv[68]={4600,4350,700,1550,650,1550,650,1600,650,450,650,450,650,450,650,450,700,400,700,1550,650,1550,650,1600,650,450,650,450,650,450,700,450,650,450,650,450,650,1550,700,450,650,450,650,450,650,450,650,450,700,400,650,1600,650,450,650,1550,650,1600,650,1550,650,1550,700,1550,650,1550,650}; // volume up unsigned int volUpTv[68]={4600,4350,650,1550,700,1500,700,1550,700,400,700,400,700,450,650,450,700,400,700,1500,700,1550,650,1550,700,400,700,400,700,450,650,450,700,400,700,1500,700,1550,650,1550,700,400,700,450,700,400,700,400,700,400,700,450,650,450,650,450,650,1550,700,1500,700,1550,700,1500,700,1550,650}; // volume down unsigned int volDownTv[68]={4600,4350,700,1550,650,1550,700,1500,700,450,650,450,700,400,700,400,700,400,700,1550,700,1500,700,1550,700,400,700,400,700,400,700,450,650,450,650,1550,700,1500,700,450,650,1550,700,400,700,400,700,450,700,400,700,400,700,400,700,1550,700,400,700,1500,700,1500,700,1550,700,1500,700}; // channel up unsigned int chUpTv[68]={4600,4350,700,1500,700,1500,700,1550,700,450,650,400,700,450,650,450,700,400,700,1500,700,1550,650,1550,700,450,650,450,700,400,700,400,700,400,700,400,700,1550,700,400,700,400,700,1550,650,450,700,400,700,400,700,1550,650,450,650,1600,650,1550,650,450,700,1500,700,1500,700,1550,650}; // channel down unsigned int chDownTv[68]={4650,4300,700,1550,700,1500,700,1550,700,400,700,400,700,400,700,450,650,450,650,1550,700,1500,700,1550,700,400,700,400,700,400,700,450,700,400,700,400,700,400,700,450,650,450,650,1550,700,400,700,450,650,400,700,1550,700,1500,700,1550,700,1500,700,400,700,1550,650,1550,700,1500,700};

// Tv/Video unsigned int videoTv[68]={4500,4300,650,1600,650,1550,650,1600,650,500,600,500,650,500,650,500,650,500,600,1650,600,1600,650,1550,650,500,650,500,650,500,600,500,650,500,650,1600,600,500,650,500,650,500,650,500,600,550,600,500,650,500,650,500,650,1550,650,1600,650,1550,650,1600,650,1550,650,1600,650,1550,650};

void setup()




void loop()




switch (dato)

{ case 'R':




case 'T':




case 'U':




case 'V':




case 'K':

//Power the TV




case 'L':

//Volume +




case 'M':

//Volume -




case 'N':

//Channel +




case 'O':

//Channel -




case 'P':

// Tv/Video




case 'A':

for (int i = 0; i < 3; i++)


ir.sendNEC(0xFF30CF, 32); // Power the DVD




case 'B':

for (int i = 0; i < 3; i++)


ir.sendNEC(0xFF00FF, 32); // Open /Close




case 'C':

for (int i = 0; i < 3; i++)


ir.sendNEC(0xFF52AD, 32); // Play




case 'D':

for (int i = 0; i < 3; i++)


ir.sendNEC(0xFF728D, 32); // Stop


} break;

} // fin del switch

} //fin del if

}//fin del loop

Step 5: The App

This is the blocks diagram of the app made in app inventor 2.

Clic here for downloading the app.

The componentes used in this app are:

  • Bluetooth client.
  • Several buttons, labels and listpicker.
  • as you can see, it is very simple, when it runs, we have to choose a bluetooth connection pressing the select device option, and when it is connected only have to press the desired button for controlling the device.

That's all. Thanks for watching and if you like this project, please vote for the home automation contest.

Again, sorry for my english.

Home Automation

Runner Up in the
Home Automation



    • Casting Contest

      Casting Contest
    • Oil Contest

      Oil Contest
    • Make it Move Contest

      Make it Move Contest

    We have a be nice policy.
    Please be positive and constructive.




    Please send me the codes that you obtain when you press the power button of your TV, those are the codes that you are shown on the serial port.

    3 replies

    Good morning,

    I've tried your project too, but when i tried, but I'm doing it with my tv, but I have no response of my tv, this is the code i got but i see when you decode you get negative numbers, and when I see your program you dont have any one.Can you help me with that, look this is the code i get:


    Decoded NEC: C1AA09F6 (32 bits)

    Raw (68): 17484 8750 -4500 500 -1700 550 -1650 500 -600 550 -550 550 -600 500 -600 500 -600 550 -1650 550 -1650 550 -600 500 -1700 500 -600 550 -1650 550 -600 500 -1700 500 -600 500 -600 550 -600 500 -600 500 -600 550 -1650 550 -600 500 -600 500 -1700 500 -1700 550 -1650 550 -1650 550 -1650 550 -600 500 -1700 500 -1700 500 -600 550

    and this is the program in arduino

    #include <IRremote.h>

    IRsend ir;

    int estado=0;

    char dato;

    int boton1 =6;

    int boton2 =7;

    unsigned int power2[68]={17484,8750,-4500,500,-1700,550,-1650,500,-600,550,-550,550,-600,500,-600,500,-600,550,-1650,550,-1650,550,-600,500,-1700,500,-600,550,-1650,550,-600,500,-1700,500,-600,500,-600,550,-600,500,-600,500,-600,550,-1650,550,-600,500,-600,500,-1700,500,-1700,550,-1650,550,-1650,550,-1650,550,-600,500,-1700,500,-1700,500,-600,550};

    void setup()






    void loop() {



    int b1= digitalRead(boton1);

    int b2= digitalRead(boton2);

    if (b1==HIGH) {







    HI, sorry for my english. If you get negative numbers, place them positive, don't place the minus (-). And deletes the first code, so use this code for the power2:
    unsigned int power2[68]=8750,4500,500,1700,550,1650,500,600,550,550,550,-600,500,600,500,600,550,1650,550,1650,550,600,500,1700,500,600,550,1650,550,600,500,1700,500,600,500,600,550,600,500,600,500,600,550,1650,550,600,500,600,500,1700,500,1700,550,1650,550,1650,550,1650,550,600,500,1700,500,1700,500,600,550};


    if that doesn't work, use this:

    for (int i = 0; i < 3; i++)
    ir.sendNEC(0xC1AA09F6 , 32); // Powers

    Hi, I've tried the solution you gave me but ir led does not turn on, I mean with the camera of my phone, doesnt turn on and i guess that my probem is located in hardware that in software.

    I've been searching trying to find a way to solve my prblem but i see you are using an arduino UNO, and I'm using a the Mega, does it has any problem with the timers and the oscilators output? and the difference betwen the boards?

    I'm doing the conections exactly you say in the instructable, and Im using the code you told me,an TSOP 1100, a Ir led and the arduino Mega.

    I've tried your project, but when I press the power tv why no response on my tv, my own program code editing with my tv Polytron.

    please solution.

    4 replies

    Could you send me the code that yo have for controlling your tv?

    I'm getting desperate, 5x I've tried still not connected with tv Polytron me, all I had to edit and according to the procedure tutorial.

    yes, but the project is not connected to my tv, I think the circuit and the code is correct.

    is there a full scheme of this project?

    yes, but the project is not connected to my tv, I think the circuit and the code is correct.

    is there a full scheme of this project?

    Hi sir.. im Planning on building that one but instead of using the phone apps.. im gonna be Using Visual basic and my Laptop. What part of the codes should I have to edit for my self to work on it..?? Any reply Would be helpful Tnx Sir...God Speed Instructables...

    1 reply

    Hi, i uploaded the project in visual basic in this link:

    The code in the arduino is the same.

    When you open the form in visual basic, select the numbert of the serial port where the arduino is connected.

    I didn't test this visual basic code, so, if there is any bug please let me know it.


    I got an error trying to obtain codes:

    Xxxxxxx.ino: In function 'void dump (decode_results*)':
    Xxxxxxx.ino:39:23:error: 'class decode_results' has no member named 'panasonicAddress'

    Pls help, I am new to this
    Thanks in advances

    Hi sistemasymicros. Thank you for your amazing project. It works for me! But i have a questions. Why when I transmit the same code from my irreceive, i need to repeat 2-6 times to get the same code from my receiver?

    2 replies

    Hi, it happened the same to me when i pressed the buttons of my stereo audio system. But i took the first code it received. It worked. I really don't know the true reason. Thanks.

    Yes, it could be, instead of using the bluettoth module we can use a wifi shield for arduino.

    I can't run the codes while compiling it shows bugs. Can you pls guide me

    1 reply