help with ir input

Here goes I am working on a kind of universal remote… the idea is by touching the corresponding part of a touch screen panel the arduino sends a infer red signal to that TV so you can control all the TV’s from one central point… I think I am almost there in the sketch I have programmed the sky TV guide button so when it receives the code for TV guide it will send it the any led that is getting a gnd from its transistor ……… when I run the sketch it runs fine but when it gets the TV guide code it goes in to I loop and will not accept any more ir in put

#include <IRremote.h>

int RECV_PIN = 11;// left hand pin on ir sensor

IRrecv irrecv(RECV_PIN);//pin 11

decode_results results;


const int analogInPin = A0;  // input from touch screen
const int analogInPin1 = A1; //input from touch screen



#include <IRremote.h>
IRsend irsend;

int sensorValue1 = 1;// value from 0 to 1023
int sensorValue = 0;  // value from 0 to 1023     
int sky6 = 1; //sky that is tuned to ch 6
int sky7 = 2;//sky that is tuned to ch 7
int sky8 = 4;//sky that is tuned to ch 8
int rrtv = 5;//to control tv in red room
int brtv = 6;//to control tv in blue room
int srtv = 7;//to control tv in smoke room
int ostv = 8;//to control tv in outside room
int tr1tv =9;//to control tv1 in tap room
int tr2tv =12;//to control tv2 in tap room




void setup() {
  pinMode(sky6, OUTPUT);
  pinMode(sky7, OUTPUT);
  pinMode(sky8, OUTPUT);  
  pinMode(rrtv, OUTPUT);
  pinMode(tr2tv, OUTPUT);
  pinMode(brtv, OUTPUT);  
  pinMode(srtv, OUTPUT);
  pinMode(ostv, OUTPUT);
  pinMode(tr1tv, OUTPUT);  



  irrecv.enableIRIn();// Start the receiver

  Serial.begin(9600);


}
void loop() {






  sensorValue = analogRead(analogInPin);            

  sensorValue1 = analogRead(analogInPin1);


  Serial.print("      " );                       
  Serial.print(sensorValue1);      
  Serial.print("      ");      
  Serial.println(sensorValue);   




  if((sensorValue1 > 530) && (sensorValue1 <662) && (sensorValue >940) && (sensorValue <1003)){



    delay(40);      
    Serial.print("sky remote ch 6"); //just to see whats going on
    digitalWrite(sky6, HIGH);//give power to Transistor to give this ir led gnd

  }



  ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 


  if((sensorValue1 > 497) && (sensorValue1 <530) && (sensorValue >859) && (sensorValue <932)){

    digitalWrite(sky7, HIGH);//give power to Transistor to give this ir led gnd
    delay(40);      
    Serial.print("sky remote ch 7"); //just to see whats going on



  }

  if((sensorValue1 > 437) && (sensorValue1 <477) && (sensorValue >793) && (sensorValue <870)){

    digitalWrite(sky8, HIGH);//give power to Transistor to give this ir led gnd
    delay(40);      
    Serial.print("sky remote ch 8"); //just to see whats going on


  }


  if((sensorValue1 > 408) && (sensorValue1 <444) && (sensorValue >741) && (sensorValue <787)){

    digitalWrite(rrtv, HIGH);//give power to Transistor to give this ir led gnd

    delay(40);      
    Serial.print("red room tv"); //just to see whats going on

  }

  if((sensorValue1 > 475) && (sensorValue1 <530) && (sensorValue >935) && (sensorValue <999)){


    digitalWrite(brtv, HIGH);//give power to Transistor to give this ir led gnd
    delay(40);      
    Serial.print("blue room tv"); //just to see whats going on

  }

  if((sensorValue1 > 144) && (sensorValue1 <475) && (sensorValue >855) && (sensorValue <900)){


    digitalWrite(tr1tv, HIGH);//give power to Transistor to give this ir led gnd
    delay(40);      
    Serial.print("tap room back tv");//just to see whats going on
  }


  if((sensorValue1 > 388) && (sensorValue1 <420) && (sensorValue >797) && (sensorValue <834)){


    digitalWrite(tr2tv, HIGH);//give power to Transistor to give this ir led gnd
    delay(40);      
    Serial.print("tap room window tv"); //just to see whats going on

  }

  if((sensorValue1 > 347) && (sensorValue1 <396) && (sensorValue >735) && (sensorValue <772)){


    digitalWrite(srtv, HIGH);//give power to Transistor to give this ir led gnd
    delay(40);      
    Serial.print("smoke room"); //just to see whats going on

  }

  if((sensorValue1 >395 ) && (sensorValue1 <460) && (sensorValue >918) && (sensorValue <992)){


    digitalWrite(ostv, HIGH);//give power to Transistor to give this ir led gnd
    delay(40);      
    Serial.print("outside tv"); //just to see whats going on

  }


  if((sensorValue1 > 253) && (sensorValue1 <315) && (sensorValue >715) && (sensorValue <783)){




    delay(40);      
    Serial.print("clear all"); //just to see whats going on
    digitalWrite(1,LOW);//turn all ir led off
    digitalWrite(2,LOW);
    digitalWrite(4,LOW);
    digitalWrite(5,LOW);
    digitalWrite(6,LOW);
    digitalWrite(7,LOW);
    digitalWrite(8,LOW);
    digitalWrite(9,LOW);
    digitalWrite(12,LOW);




  }

  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
  if(results.value == 0xc05ccc){
    irsend.sendRC6(0xc05ccc, 24); // sky tv guide

    delay(40);
    Serial.print("sky tv guide"); //just to see whats going on

  }

  delay(800); 

}

so when it receives the code for TV guide it will send it the any led that is getting a gnd from its transistor

I'm having difficulties with that sentence.

but when it gets the TV guide code it goes in to I loop and will not accept any more ir in put

And that one.

All ir ground pins are connected to there own transistor when the transistor gets power it connects the pin to ground enabling it to work

when i open the Serial monitor it give’s me 2 value's 0,1023, from my touch screen when i press a button on remote it give’s me to code fore that button but if I press the tv guide button it prints “tv guide “ over and over again and will not accept any more input from remote

When it loops printing "TV guide", it should still be printing the analogue values at the top of "loop()". Is that what you observe?

(Can you ease up on the apostrophes, and concentrate on using the shift key a little more, please?)

yes it still prints the values but i need it to look again for an ir input

thanks

Shouldn't the testing of the IR results be conditional upon "decode" returning a valid result?

after it as retuned a valid result and irsend.sendRC6(0xc05ccc, 24) delay(40); Serial.print("sky tv guide") I would then like it to look again

Ive had the same problem when working on my robot. The issue is that the buffer (either that or the variable that contains the interpreted code) is retaining that value, you need to clear it out. I can’t really see it in your code but, there may be a problem with interrupts, they must be allowed for the new IR codes to be recieved. Id also place a few serial prints in there to see if your program is running through the whole loop.

also if I remember correctly, irsend stops all other IR processes. If this is true, another irresume is required to continue reception. :smiley:

If this is true, another irresume is required to continue reception

i have tryed this with no joy........think i need to lookup interpreted as i have no idea what this is

What happens if you change this section:

 if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
  if(results.value == 0xc05ccc){
    irsend.sendRC6(0xc05ccc, 24); // sky tv guide

    delay(40);
    Serial.print("sky tv guide"); //just to see whats going on

  }

to this:

 if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
  
    if(results.value == 0xc05ccc){
      irsend.sendRC6(0xc05ccc, 24); // sky tv guide

      delay(40);
      Serial.print("sky tv guide"); //just to see whats going on
    }
    irrecv.resume(); // Receive the next value
  }

Or is the problem that you're retransmitting the same code you receive, so you're getting positive feedback?

Same thing "........seems to see tv guide and hold that value

Did you read the last part of my last post?

sorry no i did not read it.... but i have run the code with no IR LED conected just to check that

without irsend.sendRC6(0xc05ccc, 24);

the code runs .... but i need to send