解决问题系列(3)——红外发射,控制美的空调开

好久没搞红外遥控了,今天拿起来。感觉还好,对照前人们的教程贴,很快就把电路搭起来。



今天准备遥控美的空调(我手边的是美的)。



用IRremote库里面的IRdump例程,先克隆出来空调的开关,再发送回去,搞了半天,控制不了。



ARDUINO 代码复制打印

//unsigned int rawCodes_ac_open[100] = {3602,4400,4450,550,1600,550,550,550,1650,500,1650,550,550,550,550,500,1650,550,550,550,550,500,1650,550,550,550,550,500,1650,550,1650,500,550,550,1650,550,550,500,1650,550,1650,500,1650,550,1650,500,550,550,1650,550,1600,550,1650,550,550,550,500,550,550,550,550,550,1600,550,550,550,550,550,1600,550,1650,550,1600,550,550,550,550,550,550,550,500,550,550,550,550,550,550,550,500,550,1650,550,1600,550,1650,550,1600,550,1650,550};unsigned int rawCodes_ac_open[200] = {4397,4368,561,1578,560,537,557,1581,584,1582,584,486,558,537,584,1554,560,538,558,510,558,1607,557,513,585,511,556,1585,581,1583,583,486,557,1609,556,513,558,538,557,512,558,1607,558,1583,557,1608,558,1608,557,1580,559,1606,559,1581,556,1609,557,512,559,537,558,512,557,539,557,512,558,1607,558,1582,558,537,584,1555,558,1607,556,514,559,537,556,513,558,537,556,514,558,1606,559,511,583,513,558,1582,557,1608,558,1580,585,5154,4419,4347,584,1555,558,539,557,1581,584,1581,571,501,577,516,571,1568,557,541,581,487,557,1608,557,513,558,538,557,1582,583,1582,584,487,557,1608,557,511,611,486,558,510,558,1607,557,1609,556,1583,583,1582,583,1555,558,1607,558,1607,559,1582,557,537,585,486,558,510,558,540,558,509,557,1608,558,1608,557,512,559,1606,559,1581,558,537,581,490,558,510,587,511,557,511,559,1606,559,510,569,527,558,1582,560,1604,561,1605,561};unsigned int rawCodes_ac_close[100] ={25524,4400,4400,550,1650,550,550,550,1600,550,1650,550,500,550,550,550,1650,550,500,550,550,550,1650,550,500,550,550,550,1650,550,1600,550,550,550,1600,550,1650,550,550,550,1600,550,1650,550,1600,550,1650,550,1600,550,1650,550,550,500,1650,550,550,550,550,500,550,550,550,550,550,550,550,500,550,550,1650,550,550,500,550,550,550,550,550,550,550,500,550,550,1650,550,550,500,1650,550,1650,500,1650,550,1650,500,1650,550,1650,550};
//unsigned int rawCodes_ac_open[100] = {3602,4400,4450,550,1600,550,550,550,1650,500,1650,550,550,550,550,500,1650,550,550,550,550,500,1650,550,550,550,550,500,1650,550,1650,500,550,550,1650,550,550,500,1650,550,1650,500,1650,550,1650,500,550,550,1650,550,1600,550,1650,550,550,550,500,550,550,550,550,550,1600,550,550,550,550,550,1600,550,1650,550,1600,550,550,550,550,550,550,550,500,550,550,550,550,550,550,550,500,550,1650,550,1600,550,1650,550,1600,550,1650,550};

unsigned int rawCodes_ac_open[200] = {4397,4368,561,1578,560,537,557,1581,584,1582,584,486,558,537,584,1554,560,538,558,510,558,1607,557,513,585,511,556,1585,581,1583,583,486,557,1609,556,513,558,538,557,512,558,1607,558,1583,557,1608,558,1608,557,1580,559,1606,559,1581,556,1609,557,512,559,537,558,512,557,539,557,512,558,1607,558,1582,558,537,584,1555,558,1607,556,514,559,537,556,513,558,537,556,514,558,1606,559,511,583,513,558,1582,557,1608,558,1580,585,5154,4419,4347,584,1555,558,539,557,1581,584,1581,571,501,577,516,571,1568,557,541,581,487,557,1608,557,513,558,538,557,1582,583,1582,584,487,557,1608,557,511,611,486,558,510,558,1607,557,1609,556,1583,583,1582,583,1555,558,1607,558,1607,559,1582,557,537,585,486,558,510,558,540,558,509,557,1608,558,1608,557,512,559,1606,559,1581,558,537,581,490,558,510,587,511,557,511,559,1606,559,510,569,527,558,1582,560,1604,561,1605,561};

unsigned int rawCodes_ac_close[100] ={25524,4400,4400,550,1650,550,550,550,1600,550,1650,550,500,550,550,550,1650,550,500,550,550,550,1650,550,500,550,550,550,1650,550,1600,550,550,550,1600,550,1650,550,550,550,1600,550,1650,550,1600,550,1650,550,1600,550,1650,550,550,500,1650,550,550,550,550,500,550,550,550,550,550,550,550,500,550,550,1650,550,550,500,550,550,550,550,550,550,550,500,550,550,1650,550,550,500,1650,550,1650,500,1650,550,1650,500,1650,550,1650,550};



被屏蔽的第一行代码,就是用IRdump读出来的,这个不能控制空调。
第二行可以,看出来区别了吗?1个是100,一个是200。
每个数字为单片机捕获的美的空调遥控器的高低电平时间,单位为US,一高一低一高一低......详见sendRaw函数。
可以预见的是,第三行代码也不能用。

第二行的内容我也是无意中搜出来的,见下面的链接:
http://blog.21ic.com/user1/3179/archives/2010/68502.html

找到正确的序列,才可以控制。
下面是发送代码
ARDUINO 代码复制打印
Serial.print("SendIR: ");irsend.sendRaw(rawCodes_ac_open,200, 38); // 记得换成你遥控器的红外线编码delay(3000);
Serial.print("SendIR: ");
irsend.sendRaw(rawCodes_ac_open,200, 38); // 记得换成你遥控器的红外线编码
delay(3000);


无它,唯运气好而已,记录一下,防止遗忘。

解决问题系列(4)——红外编码分析利器使用


解决问题系列(2)——红外发射"未知类型"代码
via - 极客工坊

标签: Arduino教程