📜 ⬆️ ⬇️

Bluetooth remote for tv on arduino

We continue to make different smart / smart / bluetooth devices on arduino. In previous articles I talked about a bluetooth typewriter and a bluetooth voltmeter . Today we will talk about something like a bluetooth remote for the TV. Voting on the most successful name for such a device will be at the end of the article, and for the beginning I suggest to watch the video how this device works.



In the article I will tell why, how and from what I collected this device, about the advantages and disadvantages of its use, as well as a few words about the existing analogues.

First about why I decided to make a similar device. This, I think, is a very important question, because most of the friends to whom I told about this device ask, first of all, not about how it works, but about what I did this device for. It all started with the fact that after a long break, due to the advent of high-speed Internet, I decided to turn on the TV and find out if something had changed there in those few years that I did not turn it on. It turns out changed. First of all, I had 63 channels on my TV, instead of 7-8 channels that we had before. This seemed good news, until I realized that I could only watch as many of these 63 channels as I could remember. That is, if you do not remember on which channel Discovery is tuned, you will not be able to see it until you turn the channels in order. Even if you remember the number of the desired channel, you still have to contrive to press 2 buttons of the remote in a certain (short) time, hitting the sometimes erased remote control buttons in the dark. In general, this is hell, and so I decided to do something about it.
')
Now let's go directly to the device that turned out to be done. The scheme is quite simple:



Components:
Arduino nano
Bluetooth Module
IR LED

The principle of operation is also very simple. We run the application on a smartphone or tablet, it sends information with the channel number to the pre-paired bluetooth module. This module transmits the channel number to the Arduino, and the Arduino generates the desired signal to 3 pin, thereby simulating the staff remote control. I must say that the topic of managing various household appliances on the infrared channel with arduino is developed quite well, and there is an IRremote library for arduino that supports most TVs and other equipment with infrared control.

Now to the process of making bluetooth remote. To find out which Arduino signals should be sent to the TV, you must first scan the standard remote control using the standard IRremote library sketch and IR receiver . The remote control from my LG TV was scanned right away. I registered these codes in
sketch
#include <IRremote.h>
IRsend irsend;
unsigned long a;
void setup () {
Serial.begin (9600);
Serial.setTimeout (4);
pinMode (ledPin, OUTPUT);
}
void S1 () {irsend.sendNEC (0x20DF8877, 32); delay (200);}
void S2 () {irsend.sendNEC (0x20DF48B7, 32); delay (200);}
void S3 () {irsend.sendNEC (0x20DFC837, 32); delay (200);}
void S4 () {irsend.sendNEC (0x20DF28D7, 32); delay (200);}
void S5 () {irsend.sendNEC (0x20DFA857, 32); delay (200);}

void S6 () {irsend.sendNEC (0x20DF6897, 32); delay (200);}
void S7 () {irsend.sendNEC (0x20DFE817, 32); delay (200);}
void S8 () {irsend.sendNEC (0x20DF18E7, 32); delay (200);}
void S9 () {irsend.sendNEC (0x20DF9867, 32); delay (200);}
void S0 () {irsend.sendNEC (0x20DF08F7, 32); delay (200);}

void Son () {irsend.sendNEC (0x20DF10EF, 32);}

void loop ()
{
if (Serial.available ())
{a = Serial.parseInt ();
if (a == 1) {S1 ();}
if (a == 2) {S2 ();}
if (a == 3) {S3 ();}
if (a == 4) {S4 ();}
if (a == 5) {S5 ();}
if (a == 6) {S6 ();}
if (a == 7) {S7 ();}
if (a == 8) {S8 ();}
if (a == 9) {S9 ();}
if (a == 10) {S1 (); S0 ();}

if (a == 11) {S1 (); S1 ();}
if (a == 12) {S1 (); S2 ();}
if (a == 13) {S1 (); S3 ();}
if (a == 14) {S1 (); S4 ();}
if (a == 15) {S1 (); S5 ();}
if (a == 16) {S1 (); S6 ();}
if (a == 17) {S1 (); S7 ();}
if (a == 18) {S1 (); S8 ();}
if (a == 19) {S1 (); S9 ();}
if (a == 20) {S2 (); S0 ();}

if (a == 21) {S2 (); S1 ();}
if (a == 22) {S2 (); S2 ();}
if (a == 23) {S2 (); S3 ();}
if (a == 24) {S2 (); S4 ();}
if (a == 25) {S2 (); S5 ();}
if (a == 26) {S2 (); S6 ();}
if (a == 27) {S2 (); S7 ();}
if (a == 28) {S2 (); S8 ();}
if (a == 29) {S2 (); S9 ();}
if (a == 30) {S3 (); S0 ();}

if (a == 31) {S3 (); S1 ();}
if (a == 32) {S3 (); S2 ();}
if (a == 33) {S3 (); S3 ();}
if (a == 34) {S3 (); S4 ();}
if (a == 35) {S3 (); S5 ();}
if (a == 36) {S3 (); S6 ();}
if (a == 37) {S3 (); S7 ();}
if (a == 38) {S3 (); S8 ();}
if (a == 39) {S3 (); S9 ();}
if (a == 40) {S4 (); S0 ();}

if (a == 41) {S4 (); S1 ();}
if (a == 42) {S4 (); S2 ();}
if (a == 43) {S4 (); S3 ();}
if (a == 44) {S4 (); S4 ();}
if (a == 45) {S4 (); S5 ();}
if (a == 46) {S4 (); S6 ();}
if (a == 47) {S4 (); S7 ();}
if (a == 48) {S4 (); S8 ();}
if (a == 49) {S4 (); S9 ();}
if (a == 50) {S5 (); S0 ();}

if (a == 51) {S5 (); S1 ();}
if (a == 52) {S5 (); S2 ();}
if (a == 53) {S5 (); S3 ();}
if (a == 54) {S5 (); S4 ();}
if (a == 55) {S5 (); S5 ();}
if (a == 56) {S5 (); S6 ();}
if (a == 57) {S5 (); S7 ();}
if (a == 58) {S5 (); S8 ();}
if (a == 59) {S5 (); S9 ();}
if (a == 60) {S6 (); S0 ();}

if (a == 61) {S6 (); S1 ();}
if (a == 62) {S6 (); S2 ();}
if (a == 63) {S6 (); S3 ();}
if (a == 64) {S6 (); S4 ();}
if (a == 65) {S6 (); S5 ();}
if (a == 66) {Son ();}
if (a == 67) {irsend.sendNEC (0x807F48B7, 32);} // add sound
if (a == 68) {irsend.sendNEC (0x807FC837, 32);} // turn down the sound

}
}


As it turned out, these codes are suitable for other LG TVs.

A little later, I made the same bluetooth remote for the Sony TV. The codes of the buttons on the Sony remotes are also easy to read, but you need to know that this brand has every signal repeated 3 times, and the standard sketch for reading the IRremote library does not “notice” this. Therefore, in the sketch you need to repeat them 3 times. Sketch for working with Sony TV
here
#include <IRremote.h>
IRsend irsend;
int ledPin = 13;
unsigned long a;
void setup () {
Serial.begin (9600);
Serial.setTimeout (4);
pinMode (ledPin, OUTPUT);
}
void S1 () {irsend.sendSony (0x10, 12); delay (100); irsend.sendSony (0x10, 12); delay (100); irsend.sendSony (0x10, 12); delay (1000);}
void S2 () {irsend.sendSony (0x810, 12); delay (100); irsend.sendSony (0x810, 12); delay (100); irsend.sendSony (0x810, 12); delay (1000);}
void S3 () {irsend.sendSony (0x410, 12); delay (100); irsend.sendSony (0x410, 12); delay (100); irsend.sendSony (0x410, 12); delay (1000);}
void S4 () {irsend.sendSony (0xC10, 12); delay (100); irsend.sendSony (0xC10, 12); delay (100); irsend.sendSony (0xC10, 12); delay (1000);}
void S5 () {irsend.sendSony (0x210, 12); delay (100); irsend.sendSony (0x210, 12); delay (100); irsend.sendSony (0x210, 12); delay (1000);}

void S6 () {irsend.sendSony (0xA10, 12); delay (100); irsend.sendSony (0xA10, 12); delay (100); irsend.sendSony (0xA10, 12); delay (1000);}
void S7 () {irsend.sendSony (0x610, 12); delay (100); irsend.sendSony (0x610, 12); delay (100); irsend.sendSony (0x610, 12); delay (1000);}
void S8 () {irsend.sendSony (0xE10, 12); delay (100); irsend.sendSony (0xE10, 12); delay (100); irsend.sendSony (0xE10, 12); delay (1000);}
void S9 () {irsend.sendSony (0x110, 12); delay (100); irsend.sendSony (0x110, 12); delay (100); irsend.sendSony (0x110, 12); delay (1000);}
void S0 () {irsend.sendSony (0x910, 12); delay (100); irsend.sendSony (0x910, 12); delay (100); irsend.sendSony (0x910, 12); delay (1000);}

void Son () {irsend.sendSony (0xA90, 12); delay (100); irsend.sendSony (0xA90, 12); delay (100); irsend.sendSony (0xA90, 12); delay (1000);}

void loop ()
{
if (Serial.available ())
{a = Serial.parseInt ();
if (a == 1) {S1 ();}
if (a == 2) {S2 ();}
if (a == 3) {S3 ();}
if (a == 4) {S4 ();}
if (a == 5) {S5 ();}
if (a == 6) {S6 ();}
if (a == 7) {S7 ();}
if (a == 8) {S8 ();}
if (a == 9) {S9 ();}
if (a == 10) {S1 (); S0 ();}

if (a == 11) {S1 (); S1 ();}
if (a == 12) {S1 (); S2 ();}
if (a == 13) {S1 (); S3 ();}
if (a == 14) {S1 (); S4 ();}
if (a == 15) {S1 (); S5 ();}
if (a == 16) {S1 (); S6 ();}
if (a == 17) {S1 (); S7 ();}
if (a == 18) {S1 (); S8 ();}
if (a == 19) {S1 (); S9 ();}
if (a == 20) {S2 (); S0 ();}

if (a == 21) {S2 (); S1 ();}
if (a == 22) {S2 (); S2 ();}
if (a == 23) {S2 (); S3 ();}
if (a == 24) {S2 (); S4 ();}
if (a == 25) {S2 (); S5 ();}
if (a == 26) {S2 (); S6 ();}
if (a == 27) {S2 (); S7 ();}
if (a == 28) {S2 (); S8 ();}
if (a == 29) {S2 (); S9 ();}
if (a == 30) {S3 (); S0 ();}

if (a == 31) {S3 (); S1 ();}
if (a == 32) {S3 (); S2 ();}
if (a == 33) {S3 (); S3 ();}
if (a == 34) {S3 (); S4 ();}
if (a == 35) {S3 (); S5 ();}
if (a == 36) {S3 (); S6 ();}
if (a == 37) {S3 (); S7 ();}
if (a == 38) {S3 (); S8 ();}
if (a == 39) {S3 (); S9 ();}
if (a == 40) {S4 (); S0 ();}

if (a == 41) {S4 (); S1 ();}
if (a == 42) {S4 (); S2 ();}
if (a == 43) {S4 (); S3 ();}
if (a == 44) {S4 (); S4 ();}
if (a == 45) {S4 (); S5 ();}
if (a == 46) {S4 (); S6 ();}
if (a == 47) {S4 (); S7 ();}
if (a == 48) {S4 (); S8 ();}
if (a == 49) {S4 (); S9 ();}
if (a == 50) {S5 (); S0 ();}

if (a == 51) {S5 (); S1 ();}
if (a == 52) {S5 (); S2 ();}
if (a == 53) {S5 (); S3 ();}
if (a == 54) {S5 (); S4 ();}
if (a == 55) {S5 (); S5 ();}
if (a == 56) {S5 (); S6 ();}
if (a == 57) {S5 (); S7 ();}
if (a == 58) {S5 (); S8 ();}
if (a == 59) {S5 (); S9 ();}
if (a == 60) {S6 (); S0 ();}

if (a == 61) {S6 (); S1 ();}
if (a == 62) {S6 (); S2 ();}
if (a == 63) {S6 (); S3 ();}
if (a == 64) {S6 (); S4 ();}
if (a == 65) {
irsend.sendSony (0x290, 12); // Sony TV mute code
delay (100);
irsend.sendSony (0x290, 12); // Sony TV mute code
delay (100);
irsend.sendSony (0x290, 12); // Sony TV mute code
delay (100);
}
if (a == 66) {
irsend.sendSony (0xa90, 12); // Sony TV power code
delay (100);
irsend.sendSony (0xa90, 12); // Sony TV power code
delay (100);
irsend.sendSony (0xa90, 12); // Sony TV power code
delay (100);
}
if (a == 67) {
irsend.sendSony (0x490, 12); // Sony TV vol +
delay (100);
irsend.sendSony (0x490, 12); // Sony T
delay (100);
irsend.sendSony (0x490, 12); // Sony TV vol +
delay (100);
}
if (a == 68) {
irsend.sendSony (0xc90, 12); // Sony TV vol-
delay (100);
irsend.sendSony (0xc90, 12); // Sony T
delay (100);
irsend.sendSony (0xc90, 12); // Sony TV vol-
delay (100);
}
if (a == 69) {S6 (); S9 ();}
if (a == 70) {S7 (); S0 ();}

if (a == 71) {S7 (); S1 ();}
if (a == 72) {S7 (); S2 ();}
if (a == 73) {S7 (); S3 ();}
if (a == 74) {S7 (); S4 ();}
if (a == 75) {S7 (); S5 ();}
if (a == 76) {S7 (); S6 ();}
if (a == 77) {S7 (); S7 ();}
if (a == 78) {S7 (); S8 ();}
if (a == 79) {S7 (); S9 ();}
if (a == 80) {S8 (); S0 ();}

if (a == 81) {S8 (); S1 ();}
if (a == 82) {S8 (); S2 ();}
if (a == 83) {S8 (); S3 ();}
if (a == 84) {S8 (); S4 ();}
if (a == 85) {S8 (); S5 ();}
if (a == 86) {S8 (); S6 ();}
if (a == 87) {S8 (); S7 ();}
if (a == 88) {S8 (); S8 ();}
if (a == 89) {S8 (); S9 ();}
if (a == 90) {S9 (); S0 ();}

if (a == 91) {S9 (); S1 ();}
if (a == 92) {S9 (); S2 ();}
if (a == 93) {S9 (); S3 ();}
if (a == 94) {S9 (); S4 ();}
if (a == 95) {S9 (); S5 ();}
if (a == 96) {S9 (); S6 ();}
if (a == 97) {S9 (); S7 ();}
if (a == 98) {S9 (); S8 ();}
if (a == 99) {S9 (); S9 ();}
if (a == 100) {Son ();}

}
}


Video demonstration of robots from Sony:



With samsung TVs, the situation is a bit more complicated. The IRremote library does not recognize the signals of their remotes, so they simply have to be sent in the same form as they come in the RAW format.
Sketch for working with Samsung TV
#include <IRremote.h>
IRsend irsend;
unsigned long a;
void setup () {
Serial.begin (9600);
Serial.setTimeout (4);
pinMode (ledPin, OUTPUT);
}

unsigned int. 1750,450,1800,450,1700,450};
unsigned int. 1750,450,1750,500,1650,500};
unsigned int. 1700,500,1750,500,1650,500};
unsigned int'l 1700,500,1750,500,1650,500};
unsigned inthe. 1750,450,1750,500,1650,500};

unsigned int. 1750,450,1750,450,1700,500};
unsigned int. 1700,500,1750,450,1700,500};
unsigned int'l 1800,400,1800,450,1700,450};
unsigned intrinsic 1750,450,1750,500,1650,500};
unsigned int'l 1750,500,1750,450,1700,450};

unsigned int A_0 1750,450,650,450,1750,500,650,450,1700,500};
unsigned int hen 1800,400,1800,450,1700,450};

void S1 () {irsend.sendRaw (A_one, 78,38); delay (500);}
void S2 () {irsend.sendRaw (A_two, 78,38); delay (500);}
void S3 () {irsend.sendRaw (A_three, 78,38); delay (500);}
void S4 () {irsend.sendRaw (A_four, 78,38); delay (500);}
void S5 () {irsend.sendRaw (A_five, 78,38); delay (500);}

void S6 () {irsend.sendRaw (A_six, 78.38); delay (500);}
void S7 () {irsend.sendRaw (A_seven, 78,38); delay (500);}
void S8 () {irsend.sendRaw (A_eight, 78.38); delay (500);}
void S9 () {irsend.sendRaw (A_nine, 78,38); delay (500);}
void S0 () {irsend.sendRaw (A_zero, 78.38); delay (500);}

void Son () {irsend.sendRaw (A_on, 78,38); delay (500);}

void loop ()
{
if (Serial.available ())
{a = Serial.parseInt ();

if (a == 101) {Son ();}
if (a == 102) {S2 ();}
if (a == 103) {S3 ();}

if (a == 1) {S1 ();}
if (a == 2) {S2 ();}
if (a == 3) {S3 ();}
if (a == 4) {S4 ();}
if (a == 5) {S5 ();}
if (a == 6) {S6 ();}
if (a == 7) {S7 ();}
if (a == 8) {S8 ();}
if (a == 9) {S9 ();}
if (a == 10) {S1 (); S0 ();}

if (a == 11) {S1 (); S1 ();}
if (a == 12) {S1 (); S2 ();}
if (a == 13) {S1 (); S3 ();}
if (a == 14) {S1 (); S4 ();}
if (a == 15) {S1 (); S5 ();}
if (a == 16) {S1 (); S6 ();}
if (a == 17) {S1 (); S7 ();}
if (a == 18) {S1 (); S8 ();}
if (a == 19) {S1 (); S9 ();}
if (a == 20) {S2 (); S0 ();}

if (a == 21) {S2 (); S1 ();}
if (a == 22) {S2 (); S2 ();}
if (a == 23) {S2 (); S3 ();}
if (a == 24) {S2 (); S4 ();}
if (a == 25) {S2 (); S5 ();}
if (a == 26) {S2 (); S6 ();}
if (a == 27) {S2 (); S7 ();}
if (a == 28) {S2 (); S8 ();}
if (a == 29) {S2 (); S9 ();}
if (a == 30) {S3 (); S0 ();}

if (a == 31) {S3 (); S1 ();}
if (a == 32) {S3 (); S2 ();}
if (a == 33) {S3 (); S3 ();}
if (a == 34) {S3 (); S4 ();}
if (a == 35) {S3 (); S5 ();}
if (a == 36) {S3 (); S6 ();}
if (a == 37) {S3 (); S7 ();}
if (a == 38) {S3 (); S8 ();}
if (a == 39) {S3 (); S9 ();}
if (a == 40) {S4 (); S0 ();}

if (a == 41) {S4 (); S1 ();}
if (a == 42) {S4 (); S2 ();}
if (a == 43) {S4 (); S3 ();}
if (a == 44) {S4 (); S4 ();}
if (a == 45) {S4 (); S5 ();}
if (a == 46) {S4 (); S6 ();}
if (a == 47) {S4 (); S7 ();}
if (a == 48) {S4 (); S8 ();}
if (a == 49) {S4 (); S9 ();}
if (a == 50) {S5 (); S0 ();}

if (a == 51) {S5 (); S1 ();}
if (a == 52) {S5 (); S2 ();}
if (a == 53) {S5 (); S3 ();}
if (a == 54) {S5 (); S4 ();}
if (a == 55) {S5 (); S5 ();}
if (a == 56) {S5 (); S6 ();}
if (a == 57) {S5 (); S7 ();}
if (a == 58) {S5 (); S8 ();}
if (a == 59) {S5 (); S9 ();}
if (a == 60) {S6 (); S0 ();}

if (a == 61) {S6 (); S1 ();}
if (a == 62) {S6 (); S2 ();}
if (a == 63) {S6 (); S3 ();}
if (a == 64) {S6 (); S4 ();}
if (a == 65) {S6 (); S5 ();}
if (a == 66) {S6 (); S6 ();}
if (a == 67) {S6 (); S7 ();}
if (a == 68) {S6 (); S8 ();}
if (a == 69) {S6 (); S9 ();}
if (a == 70) {S7 (); S0 ();}

if (a == 71) {S7 (); S1 ();}
if (a == 72) {S7 (); S2 ();}
if (a == 73) {S7 (); S3 ();}
if (a == 74) {S7 (); S4 ();}
if (a == 75) {S7 (); S5 ();}
if (a == 76) {S7 (); S6 ();}
if (a == 77) {S7 (); S7 ();}
if (a == 78) {S7 (); S8 ();}
if (a == 79) {S7 (); S9 ();}
if (a == 80) {S8 (); S0 ();}

if (a == 81) {S8 (); S1 ();}
if (a == 82) {S8 (); S2 ();}
if (a == 83) {S8 (); S3 ();}
if (a == 84) {S8 (); S4 ();}
if (a == 85) {S8 (); S5 ();}
if (a == 86) {S8 (); S6 ();}
if (a == 87) {S8 (); S7 ();}
if (a == 88) {S8 (); S8 ();}
if (a == 89) {S8 (); S9 ();}
if (a == 90) {S9 (); S0 ();}

if (a == 91) {S9 (); S1 ();}
if (a == 92) {S9 (); S2 ();}
if (a == 93) {S9 (); S3 ();}
if (a == 94) {S9 (); S4 ();}
if (a == 95) {S9 (); S5 ();}
if (a == 96) {S9 (); S6 ();}
if (a == 97) {S9 (); S7 ();}
if (a == 98) {S9 (); S8 ();}
if (a == 99) {S9 (); S9 ();}
if (a == 100) {S1 (); S0 (); S0 (); }

}
}


Demonstration of work here:



With Arduino sorted out, now go to Android. The application is easiest to do using the visual development environment of Android-based applications App Inventor 2, although here someone is more comfortable. The application should have a simple functionality: connect to the paired bluetooth module and send the channel number to which you want to switch to it. The design of my application was very simple.



If someone wants to make the same application, I shot a video in which I explain in detail how and what to do for this. Even the one who never programmed under android can understand. (you need to go to YouTube to view)



Now a few words about the advantages and disadvantages of my bluetooth remote control. The usefulness of this device for society raises serious doubts, however, as well as the usefulness of other smart / smart / bluetooth devices, such as, for example, “smart” roulette , Bluetooth-sticker and “smart” magnet on the fridge . But personally, my bluetooth remote makes life a little easier. If earlier I did not watch TV at all, now I turn it on sometimes, and only from a smartphone or tablet, depending on what is at hand.

In general, with such a scheme, you can control not only the TV, but all devices that are controlled, but this is a slightly different story.
PS Collection of more than 100 training materials on arduino for beginners and pros here
PPS Online course on arduino to giktaimes here.
And I want to finish the survey, which promised at the beginning of the article.

Source: https://habr.com/ru/post/253471/


All Articles