irsend

Hi I wld ike a help, the led to send the cmmand is lightning but does not send anything or I dont know which form shuld i send. Im trying to do a sendRC6 but it does not send anything.

Im actually receving a comando frm a controler and reproducing to a receptor.

Thats the code:

#include <IRremote.h>


int receptor = 11;
IRrecv irrecv(receptor);
decode_results results;

int button = 12;
int ledNpCodigo = 10;

unsigned long codigo = 0; // value in decimal
int bitsTamanho = 0;
int khz = 40; // 38kHz carrier frequency for the NEC protocol

// TRNASMISSOR
IRsend irsend;
//int irTransmissor = 13;
String stringOne;
unsigned int rawBuff[68];

void setup() {
  Serial.begin(9600);
  
  pinMode(ledNpCodigo,OUTPUT); // led sinalizando que nao existe codigo
  pinMode(button, INPUT); // botao para transmitir o codigo recebido
  
  // TRANSMISSOR
  //pinMode(irTransmissor,OUTPUT); //define o pino o ledPin como saída  
  
  irrecv.enableIRIn(); //inicia o receptor
}

void loop() {             
  if (irrecv.decode(&results)){  
    //Serial.println(results.value, HEX);
    dump(&results);
    //Serial.println(results.value, HEX);
    irrecv.resume(); 
  }
  
 if (digitalRead(button)==HIGH){
       if (codigo != 0){      
         Serial.println(codigo);        
         // EMNABLE TRANSMISSOR
         digitalWrite(ledNpCodigo, LOW);          
         for (int i = 0; i <1; i++){
           //digitalWrite(irTransmissor, codigo);      
           //Serial.println(stringOne);
           irsend.sendRC6(codigo, 36); // hexa code
           //irsend.sendRC6(0xC8054275CLL, 36); // hexa code
           //irsend.sendRaw(rawBuff, 60, 38);
           delay(300);
           //irsend.sendRC6(0xC8054A75CLL, 36); // hexa code
           //delay(1000);
         }
         irrecv.enableIRIn(); //inicia o receptor
       }else{
         digitalWrite(ledNpCodigo, HIGH);
       }
     }
}

void dump(decode_results *results) {
 // Dumps out the decode_results structure.
 // Call this after IRrecv::decode()
 int count = results->rawlen;
 if (results->decode_type == RC6) {
   Serial.print("Decoded RC6: ");
 }
 Serial.print(results->value, HEX);
 codigo = results->value;
 Serial.print(" (");
 Serial.print(results->bits, DEC);
 bitsTamanho = results->bits;
 Serial.println(" bits)");
 Serial.print("Raw (");
 Serial.print(count, DEC);
 Serial.print("): ");

 for (int i = 0; i < 60; i++) {
   if (i & 1) {
     Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
   }
   else {
     Serial.write('-');
     Serial.print((unsigned long) results->rawbuf[i]*USECPERTICK, DEC);
   }
   Serial.print(" ");
   rawBuff[i]=results->rawbuf[i];
 }
 Serial.println();
 
}
 for (int i = 0; i <1; i++){

WTF? Why would anyone use a for loop to make something happen once?

Thats the code:

Well, some of it anyway. So, here is some of the answer.

You need to…

PaulS:
Well, some of it anyway. So, here is some of the answer.

You need to…

… and here is the rest of it…

Welcome to the Forum. Please read the two posts at the top of this Forum by Nick Gammon on guidelines for posting here, especially the use of code tags ("</>") when posting source code files. Also, before posting the code, use Ctrl-T in the IDE to reformat the code in a standard format, which makes it easier for us to read.

I have made a for because i was trying to send sometimes three times or more to make sure if it woud or nt work... Just tryied to make more repetitions but im sending again just once :)

And sorry, but i couldnt understand what is the problem in my code

And sorry, but i couldnt understand what is the problem in my code

The problem is that you did not post all of it, and what you did post you posted incorrectly.

aarg:
… and here is the rest of it…

Welcome to the Forum. Please read the two posts at the top of this Forum by Nick Gammon on guidelines for posting here, especially the use of code tags ("</>") when posting source code files. Also, before posting the code, use Ctrl-T in the IDE to reformat the code in a standard format, which makes it easier for us to read.

Sorry ^^ i changed now.

What is attached to pin 12 that you use for "button"? Have you tested it separately?

aarg: What is attached to pin 12 that you use for "button"? Have you tested it separately?

Yes everything is working except sendind the code that i need.

Actually my code receive the data of the controler remote and when push this button should send the data again for the setup box.

Well, I don't see how that can happen unless you use the received data in variable "results", somewhere in your transmit code. You don't. So you're not with your own plan. Or else you haven't explained it well. If English is not your native language you are forgiven.

Im trying to do a sendRC6 but it does not send anything.

How do you know it doesn't? That the receiver does not respond as you expect is no proof.

Ok I'll try to explain again. I have an IR receive and my code just save the result in a variable. When I push the button this code should be transmited what is saved in the variable ("codigo").

When I push the button, the led of transmitting works when i see with a camera, but I dont know why it is not working with the setup box, I don know if is the form that i am sending the code to the transmiter or I dont have ideia what i can try now.

The pin 12 is the push button. The pin 11 is the IR receiver. And pin 10 is just a Led which is on when i dont have any code to transmit.

The thing is that with the camera my transmiter is working, but it does not send to the setup box... And when I try to receive something from this transmiter looks like there is no code comming from it.

I hope that i have explained better now. :)

Sorry by my english, There is a time that i dont use.

You have this debug statement:

      Serial.println(codigo);

Does it print anything?

aarg:
You have this debug statement:

      Serial.println(codigo);

Does it print anything?

Yes. It prints the code of the controler when i receive it.
Normaly in Decimal.

LOGS:
RECEIVING
Decoded RC6 DEC: 2153031516
Decoded RC6 HEX: 8054A75C (36 bits)
Raw (58): -537900 2650 -850 500 -400 450 -450 450 -850 500 -850 1350 -850 450 -400 500 -400 450 -450 450 -400 500 -400 450 -450 450 -400 950 -850 900 -850 900 -850 500 -400 900 -850 900 -900 450 -400 900 -450 450 -400 500 -850 900 -850 900 -450 450 -400 500 -850 450 -400 500 -0 0
codigo: 2153031516
SENDING codigo: 2153031516

Have you ever tested the transmitter, using the IR library example sketch, instead of your program?

aarg: Have you ever tested the transmitter, using the IR library example sketch, instead of your program?

Hi, I tryed now. Actually, I put the IR Transmiter in the pin 3 on Arduino. But with the example, it's not working. '-' At least I cant see it with the camera.

PaulS: How do you know it doesn't? That the receiver does not respond as you expect is no proof.

Hi Paul, Sorry by the late response.

So. The led Shines in the camera, and the code, like i sent above - the logs, is sending the variable correct, but when I use another receptor in front of it, just dont receive anything..