Pages: [1]   Go Down
Author Topic: Infrared send and recieve  (Read 572 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone,

I have a work project involving IR. I'm suppose to send and receive IR signal with the same arduino. For sending and reciving i'm using the IRremote library, an IR receiver and an IR transmitter.
The library works perfectly when i'm using one arduino to send, and another to receive.

But when I implement the code for both receiving and sendind, I blocks on sending. That's my code
Code:
#include <IRremote.h> // Include the library

int RECV_PIN= 11; //Pin of the receiver
IRrecv irrecv(RECV_PIN); // Start the reciever

decode_results results;
IRsend irsend;

int incomingByte=0;

void setup(){
  Serial.begin(9600);
  irrecv.enableIRIn(); // enables the reciver
}

void loop (){
  if(irrecv.decode(&results)){
    Serial.println(results.value,HEX); // decodes results
    irrecv.resume();
  }
 
  if (Serial.available() > 0){
    incomingByte= Serial.read(); // if i send 1, start isend
      if(incomingByte=49){
        isend();
      }
  }
}

void isend(){
  cli();
  for (int i = 0; i < 3; i++) {
   irsend.sendSony(0xa90, 12); // Sony TV power code
   delay(40);
                }
  sei();
}
 

Until I don't send 1 to the port com, it receives IR perfectly, but when I send 1 to com, it send an IR signal but does not stop sending it. I would like to send an IR signal for a given time then go back to receiving IR.

Do anyblody has an idea ? My work project is blocked until I find a solution.

Thanks in advance

IR receiver  : http://www.dfrobot.com/index.php?route=product/product&filter_name=ir%20receiver&product_id=351#.ULE3I4faU74
IR transmitter : http://www.dfrobot.com/index.php?route=product/product&filter_name=ir%20transmitter&product_id=355#.ULE484faU74
Arduino used : http://www.zartronic.fr/dfrduino-romeo-robotique-328-rev11-compatible-arduino-p-146.html
Logged

0
Offline Offline
Shannon Member
****
Karma: 206
Posts: 12113
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Replace assignment:
Code:
      if(incomingByte=49){
by comparison:
Code:
      if(incomingByte == 49){
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Replace assignment:
Code:
      if(incomingByte=49){
by comparison:
Code:
      if(incomingByte == 49){

I already did and it didn't work. That's why I changed it. It just can't stop sending the IR signal.
Logged

Pages: [1]   Go Up
Jump to: