Blogger

Delete comment from: Ken Shirriff's blog

amen_i said...

hello, i'm trying to control my air conditioner from an arduino UNO by using the IRremote library.
at first, i try to know the format IR decoding of the remote control,
Result: UNKNOWN

so i try to decode my IR signal i use this code:
--------------------------------
#include

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

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

int c = 1;

void dump(decode_results *results) {

int count = results->rawlen;
Serial.println(c);
c++;
Serial.println("For IR Scope: ");
for (int i = 1; i < count; i++) {

if ((i % 2) == 1) {
Serial.print("+");
Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
}
else {
Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
}
Serial.print(" ");
}
Serial.println("");
Serial.println("For Arduino sketch: ");
Serial.print("unsigned int raw[");
Serial.print(count, DEC);
Serial.print("] = {");
for (int i = 1; i < count; i++) {

if ((i % 2) == 1) {
Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
}
else {
Serial.print((int)results->rawbuf[i]*USECPERTICK, DEC);
}
Serial.print(",");
}
Serial.print("};");
Serial.println("");
Serial.print("irsend.sendRaw(raw,");
Serial.print(count, DEC);
Serial.print(",38);");
Serial.println("");
Serial.println("");

}

void loop() {
if (irrecv.decode(&results)) {
dump(&results);
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}
--------------------------------
Result:
1
For IR Scope:
+4350 -4300 +550 -1600 +550 -500 +600 -1550 +650 -1500 +550 -550 +600 -450 +650 -1500 +550 -550 +550 -500 +550 -1600 +650 -450 +600 -450 +600 -1550 +550 -1600 +550 -550 +600 -1550 +550 -1600 +550 -500 +550 -1600 +550 -1600 +550 -1600 +550 -1600 +600 -1550 +600 -1550 +550 -500 +650 -1500 +650 -450 +600 -450 +550 -550 +550 -500 +650 -450 +550 -500 +600 -500 +550 -550 +600 -1500 +600 -500 +550 -1600 +600 -1550 +550 -550 +500 -550 +550 -1600 +600 -1550 +600 -450 +600 -1550 +600 -500 +550 -500 +650 -1500 +600 -1550 +550
For Arduino sketch:
unsigned int raw[100] = {4350,4300,550,1600,550,500,600,1550,650,1500,550,550,600,450,650,1500,550,550,550,500,550,1600,650,450,600,450,600,1550,550,1600,550,550,600,1550,550,1600,550,500,550,1600,550,1600,550,1600,550,1600,600,1550,600,1550,550,500,650,1500,650,450,600,450,550,550,550,500,650,450,550,500,600,500,550,550,600,1500,600,500,550,1600,600,1550,550,550,500,550,550,1600,600,1550,600,450,600,1550,600,500,550,500,650,1500,600,1550,550,};
irsend.sendRaw(raw,100,38);
DC4C5474

after that i try to send the decoded signal to my air conditioner by using this code:
-----------------------------

#include

IRsend irsend;
unsigned int raw[100] = {4350,4300,550,1600,550,500,600,1550,650,1500,550,550,600,450,650,1500,550,550,550,500,550,1600,650,450,600,450,600,1550,550,1600,550,550,600,1550,550,1600,550,500,550,1600,550,1600,550,1600,550,1600,600,1550,600,1550,550,500,650,1500,650,450,600,450,550,550,550,500,650,450,550,500,600,500,550,550,600,1500,600,500,550,1600,600,1550,550,550,500,550,550,1600,600,1550,600,450,600,1550,600,500,550,500,650,1500,600,1550,550,};
void setup()
{
Serial.begin(9600);
}

void loop() {
if (Serial.read() != -1) {
irsend.sendRaw(raw,100,38);
Serial.println("Sending......");
}
}
-----------------------------
but unfortunately, the air conditioner do not take any action.

i need a help plz.....

information: the remote control type is R51M/E (image of remote controle: http://www.codistec.com/219-large_default/remote-controler-r51m-e-bge.jpg)

Apr 24, 2013, 8:07:55 PM


Posted to A Multi-Protocol Infrared Remote Library for the Arduino

Google apps
Main menu