格力空调红外遥控调试
调通了自家格力空调的红外遥控(Y502E型号的遥控器),这里记录和分享下:直接通过IRremote dmp出遥控器的开关代码,注意这里修改了下IRremote的例子,同时把输出的第一位移到最后去。
如:关闭的编码中,15248 dmp出来时在最前面,移动到最后即可。
其它没有什么好说明的了,直接上代码:
#include <IRremote.h>
unsigned int rawCodes_ac_close ={8900,4450,650,1650,600,550,650,550,600,600,600,550,650,550,600,550,650,550,600,550,650,1650,650,550,650,1600,650,550,650,550,650,500,650,550,650,500,650,550,650,500,650,550,650,550,650,500,650,550,650,500,650,550,650,550,650,500,650,550,650,1600,650,550,650,1650,600,550,650,550,650,1600,650,550,650,15248};
unsigned int rawCodes_ac_open ={8950,4400,650,1650,650,500,650,550,650,1650,650,550,650,500,650,550,600,600,600,550,650,1650,650,500,650,1650,650,550,650,500,650,550,650,500,650,550,650,550,650,500,650,550,650,500,650,550,650,550,650,500,650,550,650,500,650,550,650,500,650,1650,650,550,650,1600,650,550,650,550,600,1650,650,550,650,32896};
IRsend irsend;
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop(){
irsend.sendRaw(rawCodes_ac_close,74, 38);
// if (irrecv.decode(&results)) {
// Serial.println(results.value, HEX);
// dump(&results);
// irrecv.resume(); // Receive the next value
//}
delay(5000);
irsend.sendRaw(rawCodes_ac_open,74, 38);
delay(5000);
}
void dump(decode_results *results) {
int count = results->rawlen;
if (results->decode_type == UNKNOWN) {
Serial.print("Unknown encoding: ");
}
else if (results->decode_type == NEC) {
Serial.print("Decoded NEC: ");
}
else if (results->decode_type == SONY) {
Serial.print("Decoded SONY: ");
}
else if (results->decode_type == RC5) {
Serial.print("Decoded RC5: ");
}
else if (results->decode_type == RC6) {
Serial.print("Decoded RC6: ");
}
else if (results->decode_type == PANASONIC) {
Serial.print("Decoded PANASONIC - Address: ");
Serial.print(results->panasonicAddress,HEX);
Serial.print(" Value: ");
}
else if (results->decode_type == JVC) {
Serial.print("Decoded JVC: ");
}
Serial.print(results->value, HEX);
Serial.print(" (");
Serial.print(results->bits, DEC);
Serial.println(" bits)");
Serial.print("Raw (");
Serial.print(count, DEC);
Serial.print("): ");
for (int i = 0; i < count; i++) {
Serial.print(results->rawbuf*USECPERTICK, DEC);
Serial.print(",");
}
Serial.println("");
}
补充下,发送模块参考
http://www.geek-workshop.com/forum.php?mod=viewthread&tid=3050
http://image.geek-workshop.com/forum/201212/31/165005csovyhq1yqy1xob3.jpg 这个看起来很牛啊
感觉220欧时,红外发射功率不够,我用的是10欧,不频繁发射的话5欧都可以 楼主,请问一下,你的红外LED功率够吗?我在淘宝上买了一个,直接接在#3上点亮,极其微弱,目测只有遥控器亮度的二十分之一左右,什么都遥控不到。该如何办呢? 我用了二楼那种放大的方案,没有接20欧的电阻,亮度挺好的呀,随便对着哪个方向都能遥控到。 :lol我也是没接20欧的电阻,遥控得感觉还可以,只是方向要对准就好。 格力的要想发送 sendRaw 则必需修改此函数 20000 分隔要发2次发送出去
//output separation period
if(buf>10000 && i !=0){
space(buf/2);
space(buf/2);
}
else{
if (i & 1) {
space(buf);
}
else {
mark(buf);
}
}
哈哈哈对控制空调表示很新奇... 都怎么摸索出来的啊?各种空调哈, 应该整个开源项目把各种常用空调都汇集起来。。 楼主,可否教教怎么 dump 出遥控器的红外代码的哈?
这个好用,但是空调的按键那么多每一次都不一样?请问这个有什么规律吗?还有你要用其他的数据比如温度的时候怎么弄啊是不是要在库里改啊 为友 发表于 2013-8-21 10:39 static/image/common/back.gif
格力的要想发送 sendRaw 则必需修改此函数 20000 分隔要发2次发送出去
//output separation period
...
还是发不出去
页:
[1]