Hello. Thank you for your help in my previous post.
I work with IR to replace TV's remote with my arduino.
First, I record my remote frequency with this sketch :
#include <IRremote.h>
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
}
}
And then i copying it to my sending sketch :
#include <IRremote.h>
IRsend ir;
int estado=0;
char dato;
//These codes are for controlling the Audio System
unsigned int powerEquipo[32]={250,1800,300,750,300,750,300,800,250,800,250,800,250,1800,300,1800,300,750,300,1800,300,750,300,750,300,750,250,1850,250,800,300};
unsigned int tvniko[100]={3350,1650,400,450,400,1300,400,400,400,450,400,450,400,450,400,400,400,450,400,450,400,450,400,450,350,450,400,450,400,1300,350,450,400,450,400,450,400,450,400,400,400,450,400,450,400,450,400,400,400,1300,400,450,400,400,400,450,400,450,400,450,400,450,350,450,400,450,400,1300,350,450,400,1300,400,1250,400,1300,400,1250,400,450,400,450,400,1250,400,450,400,1250,400,1300,400,1250,400,1300,400,450,400,1250,400};
unsigned int tvniko2[100]={3350,-1650,400,-450,400,-1300,400,-400,400,-450,400,-450,400,-450,400,-400,400,-450,400,-450,400,-450,400,-450,350,-450,400,-450,400,-1300,350,-450,400,-450,400,-450,400,-450,400,-400,400,-450,400,-450,400,-450,400,-400,400,-1300,400,-450,400,-400,400,-450,400,-450,400,-450,400,-450,350,-450,400,-450,400,-1300,350,-450,400,-1300,400,-1250,400,-1300,400,-1250,400,-450,400,-450,400,-1250,400,-450,400,-1250,400,-1300,400,-1250,400,-1300,400,-450,400,-1250,400};
//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':
for(int i=0; i<8; i++){
ir.sendRaw(powerEquipo,32,38);
delay(200);
}
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);
//ir.sendRaw(tvniko, 100, 38);
//ir.sendPanasonic(4004, 0x0100BCBD);
ir.sendRaw(tvniko2, 100, 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
The problem is when I sending the IR frequency i got the different code with my remote frequency. I need to repeat it two until eight times to get the same code. Can someone help me?