极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 25346|回复: 11

格力空调红外遥控调试

[复制链接]
发表于 2013-7-13 00:13:08 | 显示全部楼层 |阅读模式
调通了自家格力空调的红外遥控(Y502E型号的遥控器),这里记录和分享下:
直接通过IRremote dmp出遥控器的开关代码,注意这里修改了下IRremote的例子,同时把输出的第一位移到最后去。
如:关闭的编码中,15248 dmp出来时在最前面,移动到最后即可。
其它没有什么好说明的了,直接上代码:

  1. #include <IRremote.h>
  2. unsigned int rawCodes_ac_close[74] ={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};
  3. unsigned int rawCodes_ac_open[74] ={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};
  4. IRsend irsend;

  5. int RECV_PIN = 11;
  6. IRrecv irrecv(RECV_PIN);
  7. decode_results results;

  8. void setup()
  9. {
  10.   Serial.begin(9600);
  11.   irrecv.enableIRIn(); // Start the receiver
  12. }

  13. void loop(){
  14.   irsend.sendRaw(rawCodes_ac_close,74, 38);
  15. //   if (irrecv.decode(&results)) {
  16. //    Serial.println(results.value, HEX);
  17. //    dump(&results);
  18. //    irrecv.resume(); // Receive the next value
  19. //  }
  20.   delay(5000);
  21.   irsend.sendRaw(rawCodes_ac_open,74, 38);
  22.   delay(5000);
  23. }
  24. void dump(decode_results *results) {
  25.   int count = results->rawlen;
  26.   if (results->decode_type == UNKNOWN) {
  27.     Serial.print("Unknown encoding: ");
  28.   }
  29.   else if (results->decode_type == NEC) {
  30.     Serial.print("Decoded NEC: ");
  31.   }
  32.   else if (results->decode_type == SONY) {
  33.     Serial.print("Decoded SONY: ");
  34.   }
  35.   else if (results->decode_type == RC5) {
  36.     Serial.print("Decoded RC5: ");
  37.   }
  38.   else if (results->decode_type == RC6) {
  39.     Serial.print("Decoded RC6: ");
  40.   }
  41.   else if (results->decode_type == PANASONIC) {       
  42.     Serial.print("Decoded PANASONIC - Address: ");
  43.     Serial.print(results->panasonicAddress,HEX);
  44.     Serial.print(" Value: ");
  45.   }
  46.   else if (results->decode_type == JVC) {
  47.      Serial.print("Decoded JVC: ");
  48.   }
  49.   Serial.print(results->value, HEX);
  50.   Serial.print(" (");
  51.   Serial.print(results->bits, DEC);
  52.   Serial.println(" bits)");
  53.   Serial.print("Raw (");
  54.   Serial.print(count, DEC);
  55.   Serial.print("): ");
  56.   for (int i = 0; i < count; i++) {
  57.     Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
  58.     Serial.print(",");
  59.   }
  60.   Serial.println("");
  61. }
复制代码
回复

使用道具 举报

 楼主| 发表于 2013-7-13 00:20:34 | 显示全部楼层
补充下,发送模块参考
http://www.geek-workshop.com/forum.php?mod=viewthread&tid=3050
回复 支持 反对

使用道具 举报

发表于 2013-7-14 14:08:38 | 显示全部楼层
这个看起来很牛啊
回复 支持 反对

使用道具 举报

发表于 2013-7-14 14:45:27 | 显示全部楼层
感觉220欧时,红外发射功率不够,我用的是10欧,不频繁发射的话5欧都可以
回复 支持 反对

使用道具 举报

发表于 2013-7-15 09:31:31 | 显示全部楼层
楼主,请问一下,你的红外LED功率够吗?我在淘宝上买了一个,直接接在#3上点亮,极其微弱,目测只有遥控器亮度的二十分之一左右,什么都遥控不到。该如何办呢?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2013-7-15 10:42:04 | 显示全部楼层
我用了二楼那种放大的方案,没有接20欧的电阻,亮度挺好的呀,随便对着哪个方向都能遥控到。
回复 支持 反对

使用道具 举报

发表于 2013-7-15 12:44:46 | 显示全部楼层
我也是没接20欧的电阻,遥控得感觉还可以,只是方向要对准就好。
回复 支持 反对

使用道具 举报

发表于 2013-8-21 10:39:00 | 显示全部楼层
格力的要想发送 sendRaw 则必需修改此函数 20000 分隔要发2次发送出去
//output separation period
          if(buf[i]>10000 && i !=0){
                space(buf[i]/2);
                space(buf[i]/2);          
          }
        else{
            if (i & 1) {
              space(buf[i]);
            }
            else {
              mark(buf[i]);
            }
        }
回复 支持 反对

使用道具 举报

发表于 2013-8-21 12:01:17 | 显示全部楼层
哈哈哈  对控制空调表示很新奇... 都怎么摸索出来的啊?  各种空调哈, 应该整个开源项目把各种常用空调都汇集起来。。
回复 支持 反对

使用道具 举报

发表于 2013-8-21 16:27:07 | 显示全部楼层
楼主,可否教教怎么 dump 出遥控器的红外代码的哈?

回复 支持 反对

使用道具 举报

发表于 2013-8-26 09:27:41 | 显示全部楼层
这个好用,但是空调的按键那么多每一次都不一样?请问这个有什么规律吗?还有你要用其他的数据比如温度的时候怎么弄啊  是不是要在库里改啊
回复 支持 反对

使用道具 举报

发表于 2013-12-13 19:24:46 | 显示全部楼层
为友 发表于 2013-8-21 10:39
格力的要想发送 sendRaw 则必需修改此函数 20000 分隔要发2次发送出去
//output separation period
   ...

还是发不出去
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-10 14:46 , Processed in 0.040460 second(s), 25 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表