Pages: [1]   Go Down
Author Topic: IR recieving ok , freezes after transmitting  (Read 97 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi.
i'm trying to build a project that recieve IR codes from remote controls, which identify 4 specific commands
(marked as RED,BLUE,GREEN,YELLOW), and upon recieving RED it should transmit a constatnt transmission.

the problem is that it can recieve without bugs, but after it transmit it doest recieve anymore.
i attached an example output (see image), from that point on no other input can be recieved.

CODE:
Code:
#include <IRremote.h>

int RECV_PIN = 2;
int flag = 0 ;
unsigned long int RED = 3205937430;
unsigned long int GREEN = 61353670;
unsigned long int YELLOW = 2684089140;
unsigned long int BLUE = 3781012030;
int i;

decode_results results;
 IRrecv irrecv(RECV_PIN);
 IRsend irsend;

void setup() {
  Serial.begin(9600);
  irrecv.enableIRIn();// Start the receiver
}

void loop() {
  unsigned long int n;
  flag = 0;
 
  if (irrecv.decode(&results)) {
    n = results.value;
    Serial.print(" recieved: ");
    Serial.print(n);
    Serial.print("              of type: ");
    Serial.print(results.decode_type);
    Serial.print("              num if bits: ");
    Serial.print(results.bits);
    if (n == RED) {Serial.print("                                       RED        ");  flag =  1;   }
    if (n == GREEN) {Serial.print("                                   GREEN        ");  flag =  2;}
    if (n == YELLOW) {Serial.print("                                 YELLOW        ");  flag =  3;}
    if (n == BLUE) {Serial.print("                                       BLUE        ");   flag =  4;}
    Serial.print("\a\n\n");
   
    //SPECIAL CASE:
      if (flag == 1) {
          for (int i = 0; i < 3; i++) {
          irsend.sendSony(0xa90,32);
          delay(100);
          Serial.println(" sent succesfully \n");
        }
      }
     
     // Receive the next value
     irrecv.resume();
  }
 
}



thx.

output:

https://docs.google.com/file/d/0BwVKb8A86uLjMHVvTFl3U2FQQTg/edit?usp=sharing
Logged

Offline Offline
Edison Member
*
Karma: 28
Posts: 2036
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is that resume() call at the end supposed to be doing ?  That would be the next thing that I would check.
Logged

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

without it it goes over aand over on the first input recieved
Logged

Pages: [1]   Go Up
Jump to: