This simple project is about Bluetooth controlled voice TV remote with IR transmitter. This project can help you change your TV channels using your voice, with help of App called ' BT voice control '; available for Android not sure about iOS.
This app when connected to Bluetooth, converts your voice input to string and sends it to Arduino.
Connections:- IR LED --> PWM pin 3
- hc_05 tx --> 11
- hc_05 rx --> 10
- Vcc --> Vcc (+5v)
- GND --> GND
You need to include the IR library for Arduino to transmit IR signals. The library is available here: https://github.com/pravindesai/Arduino-IRremote. You have to first decode your TV remotes IR signals using code:
//------------------------------------------------------------------------------
// Include the IRremote library header
//
#include <IRremote.h>
//------------------------------------------------------------------------------
// Tell IRremote which Arduino pin is connected to the IR Receiver (TSOP4838)
//
int recvPin = 11;
IRrecv irrecv(recvPin);
//+=============================================================================
// Configure the Arduino
//
void setup ( )
{
Serial.begin(9600); // Status message will be sent to PC at 9600 baud
irrecv.enableIRIn(); // Start the receiver
}
//+=============================================================================
// Display IR code
//
void ircode (decode_results *results)
{
// Panasonic has an Address
if (results->decode_type == PANASONIC) {
Serial.print(results->address, HEX);
Serial.print(":");
}
// Print Code
Serial.print(results->value, HEX);
}
//+=============================================================================
// Display encoding type
//
void encoding (decode_results *results)
{
switch (results->decode_type) {
default:
case UNKNOWN: Serial.print("UNKNOWN"); break ;
case NEC: Serial.print("NEC"); break ;
case SONY: Serial.print("SONY"); break ;
case RC5: Serial.print("RC5"); break ;
case RC6: Serial.print("RC6"); break ;
case DISH: Serial.print("DISH"); break ;
case SHARP: Serial.print("SHARP"); break ;
case JVC: Serial.print("JVC"); break ;
case SANYO: Serial.print("SANYO"); break ;
case MITSUBISHI: Serial.print("MITSUBISHI"); break ;
case SAMSUNG: Serial.print("SAMSUNG"); break ;
case LG: Serial.print("LG"); break ;
case WHYNTER: Serial.print("WHYNTER"); break ;
case AIWA_RC_T501: Serial.print("AIWA_RC_T501"); break ;
case PANASONIC: Serial.print("PANASONIC"); break ;
case DENON: Serial.print("Denon"); break ;
}
}
//+=============================================================================
// Dump out the decode_results structure.
//
void dumpInfo (decode_results *results)
{
// Check if the buffer overflowed
if (results->overflow) {
Serial.println("IR code too long. Edit IRremoteInt.h and increase RAWBUF");
return;
}
// Show Encoding standard
Serial.print("Encoding : ");
encoding(results);
Serial.println("");
// Show Code & length
Serial.print("Code : ");
ircode(results);
Serial.print(" (");
Serial.print(results->bits, DEC);
Serial.println(" bits)");
}
//+=============================================================================
// Dump out the decode_results structure.
//
void dumpRaw (decode_results *results)
{
// Print Raw data
Serial.print("Timing[");
Serial.print(results->rawlen-1, DEC);
Serial.println("]: ");
for (int i = 1; i < results->rawlen; i++) {
unsigned long x = results->rawbuf[i] * USECPERTICK;
if (!(i & 1)) { // even
Serial.print("-");
if (x < 1000) Serial.print(" ") ;
if (x < 100) Serial.print(" ") ;
Serial.print(x, DEC);
} else { // odd
Serial.print(" ");
Serial.print("+");
if (x < 1000) Serial.print(" ") ;
if (x < 100) Serial.print(" ") ;
Serial.print(x, DEC);
if (i < results->rawlen-1) Serial.print(", "); //',' not needed for last one
}
if (!(i % 8)) Serial.println("");
}
Serial.println(""); // Newline
}
//+=============================================================================
// Dump out the decode_results structure.
//
void dumpCode (decode_results *results)
{
// Start declaration
Serial.print("unsigned int "); // variable type
Serial.print("rawData["); // array name
Serial.print(results->rawlen - 1, DEC); // array size
Serial.print("] = {"); // Start declaration
// Dump data
for (int i = 1; i < results->rawlen; i++) {
Serial.print(results->rawbuf[i] * USECPERTICK, DEC);
if ( i < results->rawlen-1 ) Serial.print(","); // ',' not needed on last one
if (!(i & 1)) Serial.print(" ");
}
// End declaration
Serial.print("};"); //
// Comment
Serial.print(" // ");
encoding(results);
Serial.print(" ");
ircode(results);
// Newline
Serial.println("");
// Now dump "known" codes
if (results->decode_type != UNKNOWN) {
// Some protocols have an address
if (results->decode_type == PANASONIC) {
Serial.print("unsigned int addr = 0x");
Serial.print(results->address, HEX);
Serial.println(";");
}
// All protocols have data
Serial.print("unsigned int data = 0x");
Serial.print(results->value, HEX);
Serial.println(";");
}
}
//+=============================================================================
// The repeating section of the code
//
void loop ( )
{
decode_results results; // Somewhere to store the results
if (irrecv.decode(&results)) { // Grab an IR code
dumpInfo(&results); // Output the results
dumpRaw(&results); // Output the results in RAW format
dumpCode(&results); // Output the results as source code
Serial.println(""); // Blank line between entries
irrecv.resume(); // Prepare for the next value
}
}
You will get an array of 'unsigned int', just copy those array for every button on remote and replace in following codes function associated to number.
#include <IRremote.h> // Download & include library from https://github.com/pravindesai/Arduino-IRremote
#include <SoftwareSerial.h>
// * An IR LED must be connected to Arduino PWM pin 3.
int khz = 38; // 38kHz carrier frequency for the NEC protocol
IRsend irsend;
SoftwareSerial BT(11, 10); //TX, RX respetively
String voice;
unsigned int x = 8950; // x is used in array instead of 8950 to save memory /*/*/*/*/
/*
* Decode your TV remotes signals using code example ' IRrecvDumpV2 ' in library https://github.com/pravindesai/Arduino-IRremote
* And replace following Arrays with your Signals_Array
*/
int zero(){
unsigned int irSignal0[] = {x,4400, 600,550, 600,550, 550,550, 550,1700, 550,600, 550,1700, 550,550,
550,600, 550,1700, 550,1700, 500,1750, 500,600, 550,1700, 550,600, 500,1700, 550,1700, 550,600, 500,600,
550,1700, 550,600, 500,1750, 500,600, 550,600, 500,600, 550,1700, 550,1700, 550,600, 500,1700, 550,600,
550,1700, 550,1700, 500,1700, 550}; //AnalysIR Batch Export (IRremote) - RAW
irsend.sendRaw(irSignal0, sizeof(irSignal0) / sizeof(irSignal0[0]), khz);
}
int one(){
unsigned int irSignal1[] = {x,4400, 550,550, 600,550, 550,550, 600,1650, 600,550, 550,1700, 550,550, 600,550, 550,1700, 550,1700,
550,1700, 550,550, 550,1700, 550,600, 550,1700, 500,1750, 500,600, 550,1700, 550,600, 500,1700, 550,
1700, 550,600, 550,550, 550,600, 550,1700, 550,550, 550,1700, 550,600, 550,550, 550,
1700, 550,1700, 550,1700, 550}; //AnalysIR Batch Export (IRremote) - RAW
irsend.sendRaw(irSignal1, sizeof(irSignal1) / sizeof(irSignal1[0]), khz);
}
int two(){
unsigned int irSignal2[] = {x,4400, 600,550, 550,550, 600,550, 600,1650, 550,550, 600,1650, 550,600, 550,600, 500,1750, 500,1700, 550,1700,
550,600, 550,1700, 500,600, 550,1700, 550,1700, 550,1700, 500,600, 550,600, 550,600, 500,1700, 550,600, 550,600, 500,600, 550,600, 500,1750,
500,1700, 550,1700, 550,600, 500,1750, 500,1700, 550,1700, 550}; //AnalysIR Batch Export (IRremote) - RAW
irsend.sendRaw(irSignal2, sizeof(irSignal2) / sizeof(irSignal2[0]), khz);
}
int three(){
unsigned int irSignal3[] = {x,4400, 550,600, 550,550, 550,600, 550,1700, 550,550, 550,1700, 550,600, 550,600, 500,1700, 550,1700, 550,
1700, 550,600, 500,1700, 550,600, 550,1700, 550,1700, 500,1750, 500,600, 550,600, 500,1750, 500,600, 550,600, 500,600, 550,600, 550,600,
500,1700, 550,1700, 550,600, 500,1750, 500,1700, 550,1700, 550,1700, 550}; //AnalysIR Batch Export (IRremote) - RAW
irsend.sendRaw(irSignal3, sizeof(irSignal3) / sizeof(irSignal3[0]), khz);
}
int four(){
unsigned int irSignal4[] = {x,4400, 600,550, 550,600, 550,550, 600,1650, 600,550, 550,1650, 600,550, 550,600, 550,1700, 550,1700, 500,
1750, 500,600, 550,1700, 550,600, 500,1700, 550,1700, 550,1700, 550,1700, 550,550, 550,1700, 550,1700, 550,600, 500,600, 550,600, 550,550,
550,600, 550,1700, 550,550, 550,600, 550,1700, 550,1700, 500,1700, 550}; //AnalysIR Batch Export (IRremote) - RAW
irsend.sendRaw(irSignal4, sizeof(irSignal4) / sizeof(irSignal4[0]), khz);
}
int five(){
unsigned int irSignal5[] = {x,4400, 600,550, 550,550, 600,550, 550,1700, 550,550, 550,1700, 550,600, 550,600, 500,1700, 550,1700, 550,
1700, 550,600, 500,1750, 500,600, 550,1700, 550,1700, 500,600, 550,1700, 550,600, 500,600, 550,1700, 550,600, 500,600, 550,600, 550,1700,
500,600, 550,1700, 550,1700, 550,600, 500,1700, 550,1700, 550,1700, 550}; //AnalysIR Batch Export (IRremote) - RAW
irsend.sendRaw(irSignal5, sizeof(irSignal5) / sizeof(irSignal5[0]), khz);
}
int six(){
unsigned int irSignal6[] = {x,4400, 600,550, 600,550, 550,550, 600,1650, 600,550, 550,1650, 600,550, 550,600, 550,1700, 550,1700, 500,
1750, 500,600, 550,1700, 550,600, 500,1700, 550,1700, 550,600, 500,1750, 500,600, 550,1700, 550,600, 500,600, 550,600, 500,600, 550,1700,
550,600, 550,1700, 500,600, 550,1700, 550,1700, 550,1700, 500,1750, 500}; //AnalysIR Batch Export (IRremote) - RAW
irsend.sendRaw(irSignal6, sizeof(irSignal6) / sizeof(irSignal6[0]), khz);
}
int seven(){
unsigned int irSignal7[] = {x,4450, 550,550, 600,550, 600,550, 550,1650, 600,550, 550,1700, 550,600, 550,600, 500,1700, 550,1700, 550,
1700, 550,600, 500,1700, 550,600, 550,1700, 550,1700, 500,600, 550,600, 550,1700, 500,1750, 500,1700, 550,600, 550,550, 550,600, 550,1700,
550,1700, 500,600, 550,600, 550,550, 550,1700, 550,1700, 550,1700, 550}; //AnalysIR Batch Export (IRremote) - RAW
irsend.sendRaw(irSignal7, sizeof(irSignal7) / sizeof(irSignal7[0]), khz);
}
int eight(){
unsigned int irSignal8[] = {x,4400, 600,550, 550,550, 600,550, 550,1700, 550,550, 600,1650, 550,600, 550,600, 550,1650, 550,1700, 550,
1700, 550,600, 550,1700, 500,600, 550,1700, 550,1700, 550,1700, 500,1750, 500,600, 550,600, 500,1750, 500,600, 550,600, 500,600, 550,600,
550,600, 500,1700, 550,1700, 550,600, 500,1750, 500,1700, 550,1700, 550}; //AnalysIR Batch Export (IRremote) - RAW
irsend.sendRaw(irSignal8, sizeof(irSignal8) / sizeof(irSignal8[0]), khz);
}
int nine(){
unsigned int irSignal9[] = {x,4400, 600,500, 600,550, 600,550, 550,1650, 600,550, 550,1700, 550,550, 600,550, 550,1700, 550,1700, 550,
1700, 550,600, 500,1700, 550,600, 550,1700, 550,1700, 500,1700, 550,1700, 550,600, 550,1700, 500,600, 550,600, 550,550, 550,600, 550,600,
500,600, 550,1700, 550,600, 500,1700, 550,1700, 550,1700, 550,1700, 550}; //AnalysIR Batch Export (IRremote) - RAW
irsend.sendRaw(irSignal9, sizeof(irSignal9) / sizeof(irSignal9[0]), khz);
}
void setup() {
BT.begin(9600);
Serial.begin(9600);
}
void loop() {
while (BT.available()){ //Check if there is an available byte to read
delay(10); //Delay added to make thing stable
char c = BT.read(); //Conduct a serial read
if (c == '#') {break;} //Exit the loop when the # is detected after the word
voice += c; //Shorthand for voice = voice + c
}
if (voice.length() > 0) {
Serial.println(voice);
for(int i=1;i<sizeof(voice);i++)
{
Serial.println(voice[i]);
switch(voice[i])
{
case'0': zero(); break;
case'1': one(); break;
case'2': two(); break;
case'3': three(); break;
case'4': four(); break;
case'5': five(); break;
case'6': six(); break;
case'7': seven(); break;
case'8': eight(); break;
case'9': nine(); break;
}
delay(100);
}
voice="";
}
}
So, whenever you send a string like '907' it will transmit a IR signal, 1st for 9 and then 0 and then 7 and work like TV remote.
Make sure you keep IR LED pointing towards TV. Hope you like it (its my 1st time of sharing projects online)
TWITTER: https://twitter.com/pravindesai__
Comments