problem with RF tv control

hello friends:

i try to send signal infra red to my tv but not work.

i have already all codecs of RF os my tv but it is not nec o sony its "unknow".

when i put all those codecs in the code for send to tv not work.

i dont know if is because the codecs os RF its wrong o the code to send arduino its wrong.

this its the code i use for send singnal to tv:

#include <boarddefs.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#include <ir_Lego_PF_BitStreamEncoder.h>

#include "IRremote.h"

int intByte; 
IRsend irsend;
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

//YES remote control definition 
const long ONE = 0xD41; 
const long TWO = 0x213C946B;
const long THREE = 0x213C9C63;
const long FOUR = 0x213C14EB;
const long FIVE = 0x213C04FB;
const long SIX = 0x213C1CE3;
const long SEVEN = 0x213C4CB3;
const long EIGHT = 0x213C54AB;
const long NINE = 0x213C44BB;
const long ZERO = 0x213CCC33;
const long POWER = 0x213C847B;
const long YES_BUTTON = 0x213CC43B;
const long BACK = 0x213C5CA3;
const long INFO = 0x213C3CC3;
const long CHANNEL_UP = 0x213CAC53; 
const long CHANNEL_DOWN = 0x213CEC13; 
const long MUTE = 0xD; //TV mute
const long VOL_UP = 0x10; //TV volume up
const long VOL_DOWN = 0x11; //TV volume up


void setup()
{ 
  Serial.begin(9600); 
  pinMode(13, OUTPUT);
} 

void loop()
{
  if (Serial.available()>0)
  {
    intByte = Serial.read(); 
    if (intByte >47 && intByte<58) 
    {
      //Serial.print("channel "); 
      intByte = intByte-48;
      //Serial.println(intByte, DEC);
      if (intByte == 1){ irsend.sendNEC(ONE, 32); }
      if (intByte == 2){ irsend.sendNEC(TWO, 32); }
      if (intByte == 3){ irsend.sendNEC(THREE, 32); }
      if (intByte == 4){ irsend.sendNEC(FOUR, 32); }
      if (intByte == 5){ irsend.sendNEC(FIVE, 32); }
      if (intByte == 6){ irsend.sendNEC(SIX, 32); }
      if (intByte == 7){ irsend.sendNEC(SEVEN, 32); }
      if (intByte == 8){ irsend.sendNEC(EIGHT, 32); }
      if (intByte == 9){ irsend.sendNEC(NINE, 32); }
      if (intByte == 0){ irsend.sendNEC(ZERO, 32); }
      blinkLED(1); 
      delay(210);
    } 
    else
    {
     if (intByte==80){ irsend.sendNEC(POWER, 32);} //power command
     if (intByte==73) {irsend.sendNEC(INFO, 32);} //info command
     if (intByte==66) {irsend.sendNEC(BACK, 32);} //back command
     if (intByte==89) {irsend.sendNEC(YES_BUTTON, 32);} //yes button command
     if (intByte==85) {irsend.sendNEC(CHANNEL_UP, 32);} //up command
     if (intByte==68) {irsend.sendNEC(CHANNEL_DOWN, 32);} //down channel command
     if (intByte==77) {irsend.sendRC5(MUTE, 12);} //down channel command
     if (intByte==43) {irsend.sendRC5(VOL_UP, 12); blinkLED(5);} //down channel command
     if (intByte==45) {irsend.sendRC5(VOL_DOWN, 12); blinkLED(4);} //down channel command
    }
  }
}


void blinkLED(int i)
{
   for (i; i>0; i--)
  {
    //blink LED
    digitalWrite(13, HIGH); 
    delay(100); 
    digitalWrite(13, LOW);
    delay(250); 
  } 
}

the codecs are similar of this:

D41
D63
564
543
D44
D46
574

i think its hexa codecs but i am lost with this.

if someone know how i can make this work or know any tutorial abuout this conection.

thanks very much for help me.

First of all, RF is different from IR. What does your TV set really expect?

If it's IR, you can use one of the dump examples of the IRremote library, to find out what codes and protocol your remote control does send. If the protocol is "unknown", you can use the reported raw data and sendRaw().

thank you for your anwer.

i am going to try that. its posible work with that you said.

i tell you if work or not.

thanks again friend.

hello friends:

tis is the code i hace capture con IR:

89857D7C
Unknown encoding: 89857D7C (32 bits)
Raw (16): -12100 50 -100 50 -50 100 -50 50 -50 50 -50 250 -100 6700 -50 50 
D41
Decoded RC5: D41 (12 bits)
Raw (22): 23126 800 -850 800 -850 800 -850 1650 -1650 1650 -1650 1600 -900 800 -850 800 -850 800 -850 800 -1700 750 
543
Decoded RC5: 543 (12 bits)
Raw (20): -11418 800 -850 1650 -1700 1600 -1700 1600 -1700 1600 -850 800 -850 800 -850 800 -1700 800 -850 800 
D44
Decoded RC5: D44 (12 bits)
Raw (20): -19730 750 -900 800 -850 800 -850 1600 -1700 1600 -1700 1600 -850 800 -850 800 -1700 1600 -850 800 
545
Decoded RC5: 545 (12 bits)
Raw (18): 15460 800 -850 1650 -1650 1650 -1650 1650 -1650 1650 -850 800 -850 800 -1650 1650 -1700 750 
D46
Decoded RC5: D46 (12 bits)
Raw (20): 15720 800 -850 800 -850 800 -850 1650 -1650 1650 -1650 1650 -850 800 -850 800 -1700 800 -850 1600 
547
Decoded RC5: 547 (12 bits)
Raw (20): -6548 800 -850 1650 -1650 1650 -1650 1650 -1650 1650 -850 800 -850 800 -1650 850 -850 800 -850 800 
D48
Decoded RC5: D48 (12 bits)
Raw (20): 16652 800 -850 800 -850 800 -850 1650 -1650 1650 -1650 1650 -850 800 -1650 1600 -900 800 -850 800 
549
Decoded RC5: 549 (12 bits)
Raw (18): 10452 800 -850 1600 -1700 1600 -1700 1650 -1650 1650 -850 800 -1650 1600 -900 800 -1650 800 
D4A
Decoded RC5: D4A (12 bits)
Raw (18): -14484 800 -850 800 -850 800 -850 1650 -1650 1650 -1650 1650 -850 800 -1650 1650 -1650 1650 
54B
Decoded RC5: 54B (12 bits)
Raw (18): 25838 800 -850 1650 -1650 1650 -1700 1600 -1700 1600 -850 850 -1650 1600 -1700 800 -850 800 
D4C
Decoded RC5: D4C (12 bits)
Raw (20): -24998 800 -850 800 -850 800 -850 1650 -1650 1650 -1650 1650 -850 800 -1650 800 -850 1650 -850 800 
55A
Decoded RC5: 55A (12 bits)
Raw (16): 6410 800 -850 1650 -1650 1650 -1650 1650 -1650 1650 -1650 800 -850 1600 -1700 1650 
55A
Decoded RC5: 55A (12 bits)
Raw (16): -18664 800 -900 1600 -1700 1600 -1700 1600 -1700 1600 -1700 800 -850 1600 -1700 1600 
D5A
Decoded RC5: D5A (12 bits)
Raw (18): 156 850 -800 850 -800 850 -800 1650 -1700 1600 -1700 1600 -1700 800 -850 1600 -1700 1600 
D5A
Decoded RC5: D5A (12 bits)
Raw (18): -18714 800 -850 800 -850 800 -850 1650 -1650 1600 -1700 1650 -1650 800 -850 1650 -1650 1650 
559
Decoded RC5: 559 (12 bits)
Raw (18): -24220 800 -900 1600 -1650 1650 -1650 1650 -1650 1650 -1650 800 -850 1650 -850 800 -1650 800 
D41
Decoded RC5: D41 (12 bits)
Raw (22): -13218 800 -850 800 -850 800 -850 1600 -1700 1600 -1700 1650 -800 850 -800 850 -800 850 -850 750 -1700 800

but when i put in the code example like this:

#include <IRremote.h>

IRsend irsend;
unsigned int raw2[22] = {23126 800 -850 800 -850 800 -850 1650 -1650 1650 -1650 1600 -900 800 -850 800 -850 800 -850 800 -1700 750}

void setup()
{
  Serial.begin(9600);
}


void loop() {
  if (Serial.read()!= -1){
	for (int i = 0; i < 1; i++) {
		irsend.sendRaw(raw2,96,38);
		delay(1000);
	}
	
}
}

show this wrong in the arduino program:

exit status 1
expected '}' before numeric constant

someone know how can i make the right code?

thanks very much for help.

(deleted)

thanks friend for your help. this its the code i using but i want to know how put sendRaw:

#include <boarddefs.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#include <ir_Lego_PF_BitStreamEncoder.h>

#include "IRremote.h"

int intByte; 
IRsend irsend;
unsigned int raw2[22] = {23126 800 -850 800 -850 800 -850 1650 -1650 1650 -1650 1600 -900 800 -850 800 -850 800 -850 800 -1700 750}
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;



//YES remote control definition 
const long ONE = 0xD41; 



void setup()
{ 
  Serial.begin(9600); 
  pinMode(13, OUTPUT);
} 

void loop()
{
  if (Serial.available()>0)
  {
    intByte = Serial.read(); 
    if (intByte >47 && intByte<58) 
    {
      //Serial.print("channel "); 
      intByte = intByte-48;
      //Serial.println(intByte, DEC);
      if (intByte == 1){ irsend.sendRaw(ONE, 12); }
      
      blinkLED(1); 
      delay(210);
    } 
    else
    {
     if (intByte==80){ irsend.sendNEC(POWER, 32);} //power command
     if (intByte==73) {irsend.sendNEC(INFO, 32);} //info command
     if (intByte==66) {irsend.sendNEC(BACK, 32);} //back command
     if (intByte==89) {irsend.sendNEC(YES_BUTTON, 32);} //yes button command
     if (intByte==85) {irsend.sendNEC(CHANNEL_UP, 32);} //up command
     if (intByte==68) {irsend.sendNEC(CHANNEL_DOWN, 32);} //down channel command
     if (intByte==77) {irsend.sendRC5(MUTE, 12);} //down channel command
     if (intByte==43) {irsend.sendRC5(VOL_UP, 12); blinkLED(5);} //down channel command
     if (intByte==45) {irsend.sendRC5(VOL_DOWN, 12); blinkLED(4);} //down channel command
    }
  }
}


void blinkLED(int i)
{
   for (i; i>0; i--)
  {
    //blink LED
    digitalWrite(13, HIGH); 
    delay(100); 
    digitalWrite(13, LOW);
    delay(250); 
  } 
}

unsigned int raw2[22] = {23126 800 -85See reply #4.
Also needs more semicolon

this is the new code:

#include <boarddefs.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#include <ir_Lego_PF_BitStreamEncoder.h>

#include "IRremote.h"

int intByte;
IRsend irsend;
unsigned int raw2[22] = {23126 800 -850 800 -850 800 -850 1650 -1650 1650 -1650 1600 -900 800 -850 800 -850 800 -850 800 -1700 750};
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

//YES remote control definition
const long ONE = 0xD41;

void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
}

void loop()
{
if (Serial.available()>0)
{
intByte = Serial.read();
if (intByte >47 && intByte<58)
{
//Serial.print("channel ");
intByte = intByte-48;
//Serial.println(intByte, DEC);
if (intByte == 1){ irsend.sendRaw(ONE, 12); }

blinkLED(1);
delay(210);
}
else
{
if (intByte==80){ irsend.sendNEC(POWER, 12);} //power command

}
}
}

void blinkLED(int i)
{
for (i; i>0; i--)
{
//blink LED
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
delay(250);
}
}

do you see any wrong??

An array in C / C++ looks like this:

int raw2[22] = {23126, 800, -850, 800, -850, 800, -850, 1650, -1650, 1650, -1650, 1600, -900, 800, -850, 800, -850, 800, -850, 800, -1700, 750};

Use a comma separator, not a space.

Also, I can see negative numbers but your array is of type unsigned int.

now apear this:

no matching function for call to 'IRsend::sendRaw(const long int&, int)'

in this line:

void loop()
{
if (Serial.available()>0)
{
intByte = Serial.read();
if (intByte >47 && intByte<58)
{
//Serial.print("channel ");
intByte = intByte-48;
//Serial.println(intByte, DEC);
if (intByte == 1){ irsend.sendRaw(ONE, 12); } /here

blinkLED(1);
delay(210);
}

now i use a new code. i think this is more clear:

#include <IRremote.h> // use the library
 
IRsend irsend;
 
unsigned int canal1[22] = {23126, 800, 850, 800, 850, 800, 850, 1650, 1650, 1650, 1650, 1600, 900, 800, 850, 800, 850, 800, 850, 800, 1700, 750};
unsigned int canal2[22] = {23126, 800, 850, 800, 850, 800, 850, 1650, 1650, 1650, 1650, 1600, 900, 800, 850, 800, 850, 800, 850, 800, 1700, 750};
unsigned int canal3[42] = {2650, 850, 450, 850, 450, 450, 450, 400, 450, 900, 900, 400, 500, 350, 450, 450, 450, 450, 450, 400, 450, 450, 500, 350, 500, 400, 500, 350, 500, 400, 500, 350, 500, 400, 500, 400, 450, 400, 950, 350, 500};
unsigned int canal4[40] = {2700, 850, 450, 850, 450, 450, 450, 400, 1350, 1300, 450, 400, 450, 450, 450, 400, 500, 400, 500, 400, 450, 400, 500, 400, 450, 400, 500, 400, 450, 400, 500, 400, 500, 350, 950, 850, 450, 400, 500};
unsigned int canal5[40] = {2700, 800, 500, 850, 450, 400, 500, 400, 450, 850, 950, 400, 450, 400, 500, 400, 450, 400, 500, 400, 450, 400, 500, 400, 500, 350, 500, 400, 500, 400, 450, 400, 500, 400, 450, 400, 950, 800, 950};
unsigned int canal6[40] = {2650, 850, 500, 850, 450, 400, 450, 450, 1350, 1250, 450, 450, 500, 350, 500, 400, 500, 400, 450, 400, 500, 400, 450, 400, 500, 400, 450, 400, 500, 400, 450, 400, 500, 400, 900, 400, 500, 850, 450};
unsigned int canal7[42] = {2700, 850, 450, 850, 500, 400, 450, 400, 500, 850, 900, 400, 450, 400, 500, 400, 500, 350, 500, 400, 500, 400, 450, 400, 500, 400, 450, 400, 500, 400, 450, 400, 500, 400, 500, 350, 950, 400, 450, 400, 500};
unsigned int canal8[40] = {2700, 850, 450, 850, 450, 450, 450, 400, 1350, 1300, 450, 400, 500, 400, 500, 350, 500, 400, 500, 400, 450, 400, 500, 400, 450, 400, 500, 400, 500, 350, 500, 400, 900, 850, 500, 400, 450, 400, 500};
unsigned int canal9[40] = {2650, 850, 500, 800, 500, 400, 450, 400, 500, 850, 900, 400, 500, 400, 450, 400, 500, 400, 450, 400, 500, 400, 500, 350, 500, 400, 500, 400, 450, 400, 500, 400, 450, 400, 950, 800, 500, 400, 900};
unsigned int canal0[42] = {2650, 850, 450, 850, 500, 400, 450, 450, 1350, 1250, 450, 450, 450, 400, 450, 450, 450, 400, 500, 400, 450, 450, 450, 400, 450, 450, 450, 400, 500, 400, 450, 400, 500, 400, 450, 400, 500, 400, 500, 400, 450};
unsigned int volumeUp[42] = {2650, 850, 450, 850, 500, 400, 450, 400, 500, 850, 900, 400, 500, 400, 450, 400, 500, 400, 450, 400, 500, 400, 450, 450, 450, 400, 500, 350, 500, 400, 500, 400, 900, 850, 450, 400, 500, 400, 450, 400, 500};
unsigned int volumeDown[38] = {2650, 850, 450, 900, 450, 400, 450, 450, 1350, 1250, 500, 400, 450, 450, 450, 400, 450, 450, 450, 400, 450, 450, 450, 400, 500, 400, 450, 400, 500, 400, 900, 850, 500, 400, 450, 400, 950};
unsigned int tvOnOff[22] = {23126, 800, 850, 800, 850, 800, 850, 1650, 1650, 1650, 1650, 1600, 900, 800, 850, 800, 850, 800, 850, 800, 1700, 750};
  
int canal = 0;
 
void setup()
{
  Serial.begin(9600);
 
}

void canalUno()
{
  irsend.sendRaw(canal1,22,38);
  delay(100);
}

void canalDos()
{
  irsend.sendRaw(canal2,40,38);
  delay(100);
}

void canalTres()
{
  irsend.sendRaw(canal3,42,38);
  delay(100);
}

void canalCuatro()
{
  irsend.sendRaw(canal4,40,38);
  delay(100);
}

void canalCinco()
{
  irsend.sendRaw(canal5,40,38);
  delay(100);
}

void canalSeis()
{
  irsend.sendRaw(canal6,40,38);
  delay(100);
}

void canalSiete()
{
  irsend.sendRaw(canal7,42,38);
  delay(100);
}

void canalOcho()
{
  irsend.sendRaw(canal8,40,38);
  delay(100);
}

void canalNueve()
{
  irsend.sendRaw(canal9,40,38);
  delay(100);
}

void canalCero()
{
  irsend.sendRaw(canal0,42,38);
  delay(100);
}

void subirVolumen()
{
  irsend.sendRaw(volumeUp,42,38);
  delay(100);
}

void bajarVolumen()
{
  irsend.sendRaw(volumeDown,38,38);
  delay(100);
}

void onoffTV()
{
  irsend.sendRaw(tvOnOff,22,38);
  delay(100);
}



 
 
void loop() {
      // @param1 Raw data
      // @param2 length
      // @param3 frequency, (most devices use 38khz)
      if (Serial.available() > 0)
      {
        canal = Serial.read();
        switch(canal)
        {
          case 49: // tecla 1
          canalUno();
          break;
          
          case 50: // tecla 2
          canalDos();
          break;
          
          case 51: // tecla 3
          canalTres();
          break;
          
          case 52: // tecla 4
          canalCuatro(); 
          break;
          
          case 53: // tecla 5
          canalCinco(); 
          break;
          
          case 54: // tecla 6
          canalSeis(); 
          break;
          
          case 55: // tecla 7
          canalSiete(); 
          break;
          
          case 56: // tecla 8
          canalOcho();
          break;
          
          case 57: // tecla 9
          canalNueve();
          break;
          
          case 111: //tecla 0
          canalCero();
          break;
          
          case 113: //tecla Q
          subirVolumen();
          break;
          
          case 97: //tecla A
          bajarVolumen();
          break;
          
          case 119: //tecla W
          onoffTV();
          break;
          
                 
         }


        }
       
}

but not work also

You may have to send a code multiple times, until it's accepted. A remote control does this while a button is pressed.

Did you notice that canal1 and canal2 are identical?

thanks friends.

yes canal 1 and 2 its same its onli for r try that.

i dont know its because the IR led is bad connection or far of television.

If you use IR sender diodes, you can measure the current flow, in order to find out their polarity. The orientation with more current is okay. If no current flows at all, the diode is broken.

Is the IR LED modulated at all? They usually need to be for the TVs receiver.
Say a 38Khz carrier or whatever.

You can check the LED actually works with a camera phone. Just press buttons and check to see if it lights by having your camera phone in "photo" mode like you are taking a picture. Should see a faint purple/lilac like flashing.

thanks again friends for help me.

i dont know if is modulate

i tried to see with mobile camara but i dont see nothing. i change the diode for new one.

the diode its put now in the pin 13 directly for check but i dont see any lilac light with mobile camara.

cibermiguel:
I change the diode for new one.

the diode its put now in the pin 13 directly for check but i dont see any lilac light with mobile camara.

With a ~100ohm resistor in series?

the resistor i use is 10K.

The rule for current, voltage and resistance is as follows:

I = V / R

Current = Voltage divided by Resistance.

5mm LEDs are usually brightest at about a current of ~35mA (0.0035A) (THERE IS A LOT OF VARIANCE IN THIS!).

At 5 volts and with a resistance of 10,000 ohms, you are running a current of 0.00005A...or about 0.5mA...around 1/70th of a "regular" LED.

You may not be able to see it because you are using a far too high value resistor.

When modulated, the LED is even "half on" and "half off", so for IR LEDs, a current of 70mA is not un-heard of (and about what I use in my designs at 5V).

R = V/I = 5V / 0.07mA =~71ohms.

Shove a 100om resistor there instead and come back with your findings.

5mm LEDs are usually brightest at about a current of ~35mA (0.0035A) (THERE IS A LOT OF VARIANCE IN THIS!).

Amen.
35mA is 0.035A. :wink: