Project tutorial

TV,DVD & Audio Control from Android and Arduino © GPL3+

Learn how to control some of your home appliances from your smartphone with android and arduino.

  • 5,067 views
  • 1 comment
  • 19 respects

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
×1
Bluetoth module HC05
×1
TSOP 1738
×1
Infrared led
×2
Mfr 25fbf52 221r sml
Resistor 221 ohm
×2

Apps and online services

About this project


Hi everybody, 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.

It is divided 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

#include int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup() {

Serial.begin(9600);

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(results->panasonicAddress,HEX);

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); }

else

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

Serial.print(" "); }

Serial.println(""); }

void loop()

{

if (irrecv.decode(&results))

{

Serial.println(results.value, HEX);

dump(&results);

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.

Mounting:



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:

PIN

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.

The App

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

Clic here for downloading the app.

The components 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 like the YouTube video.


Code

Arduino codeArduino
#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()

{

Serial.begin(9600);

}

void loop()

{

if(Serial.available()>0)

{ dato=Serial.read();

switch (dato)

{ case 'R':

ir.sendRaw(powerEquipo,32,38);

delay(500);

break;

case 'T':

ir.sendRaw(chEmisoraUp,32,38);

delay(100);

break;

case 'U':

ir.sendRaw(chEmisoraDown,32,38);

delay(100);

break;

case 'V':

ir.sendRaw(playCd,32,38);

delay(100);

break;

case 'K':

//Power the TV

ir.sendRaw(pwrTv,68,38);

delay(100);

break;

case 'L':

//Volume +

ir.sendRaw(volUpTv,68,38);

delay(100);

break;

case 'M':

//Volume -

ir.sendRaw(volDownTv,68,38);

delay(100);

break;

case 'N':

//Channel +

ir.sendRaw(chUpTv,68,38);

delay(100);

break;

case 'O':

//Channel -

ir.sendRaw(chDownTv,68,38);

delay(100);

break;

case 'P':

// Tv/Video

ir.sendRaw(videoTv,68,38);

delay(100);

break;

case 'A':

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

{

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

delay(40);

}

break;

case 'B':

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

{

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

delay(40);

}

break;

case 'C':

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

{

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

delay(40);

}

break;

case 'D':

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

{

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

delay(40);

} break;

} // fin del switch

} //fin del if

}//fin del loop

Schematics

Diagram of the proyect
Diagrama final
Diagram of the proyect
Protoboard bb h
Mounting in the protoboard
Protoboard final
Diagram for receiving the infrared codes.
Diagrama 1

Comments

Similar projects you might like

Arduino Bluetooth Basic Tutorial

by Mayoogh Girish

  • 454,669 views
  • 42 comments
  • 236 respects

Home Automation Using Raspberry Pi 2 And Windows 10 IoT

Project tutorial by Anurag S. Vasanwala

  • 285,524 views
  • 95 comments
  • 671 respects

Security Access Using RFID Reader

by Aritro Mukherjee

  • 229,393 views
  • 38 comments
  • 236 respects

OpenCat

Project in progress by Team Petoi

  • 195,999 views
  • 154 comments
  • 1,363 respects
Add projectSign up / Login