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);
}