解码过程和发送过程参见帖子一,数据扩展参见帖子二。
https://www.arduino.cn/thread-3618-1-1.html
// 奈何哥哥教你推倒Arduino-红外遥控~
#include
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
}
void dump(decode_results *results) {
int count = results->rawlen;
Serial.print("Raw (");
Serial.print(count, DEC);
Serial.print("): ");
for (int i = 0; i < count; i++) {
if ((i % 2) == 1) {
Serial.print((int)results->rawbuf[i]*USECPERTICK, DEC);
} //原贴此处有错误
else {
Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
}//原贴此处有错误
Serial.print(" ");
}
Serial.println("");
}
void loop() {
if (irrecv.decode(&results)) {
dump(&results);
irrecv.resume();
}
}
//奈何哥哥和你一起逆袭Arduino~红外控制
#include
IRsend irsend;
unsigned int buf[243]=
{8300,4150,550,600,500,1550,600,1600,500,600,500,1600,550,600,500,1550,600,500,550,1650,500,1600,550,1600,550,550,550,1550,550,1650,500,1650,500,550,550,550,550,550,500,550,550,550,550,550,500,600,500,600,500,550,500,1600,550,550,550,550,550,550,500,550,550,550,550,600,450,600,450,600,550,1600,550,550,500,600,500,550,550,1600,550,550,500,550,550,550,550,550,550,550,500,550,550,550,550,550,500,550,550,550,550,550,550,550,500,550,550,550,500,600,500,550,550,550,550,550,500,600,500,550,550,550,500,600,500,550,550,550,500,600,500,550,550,550,550,550,500,550,550,550,550,550,500,550,550,550,550,550,500,600,500,550,550,550,500,600,500,550,550,550,550,550,500,550,550,550,550,550,550,550,500,550,550,550,550,550,500,550,550,550,550,550,500,550,550,550,550,550,500,600,500,550,550,550,500,600,500,550,550,550,550,550,500,550,550,550,550,550,500,600,500,550,550,550,500,600,500,550,550,550,500,600,500,550,550,550,550,550,500,550,550,1600,550,1600,550,1600,550,1600,550,500,550,550,550,550,550
};
//格力空调开机关机时140位。
void setup()
{
}
void loop() {
irsend.sendRaw(buf,243,38);
delay(3000);
}
================================================================================================================================================================================================================================================
https://www.geek-workshop.com/thread-5146-1-1.html
你要找到如下三个文件
IRremote.ccp IRremote.h IRremoteInt.h ,在 arduino 安装目录下的libraries\arduino_iremote_master
也就是你的库文件,如果没有请参考帖子下载
#define RAWBUF 270 // Length of raw duration buffer
// Marks tend to be 100us too long, and spaces 100us too short
// when received due to sensor lag.
这个默认值是100,因为我们接收的数据会超过100,所以在这里改成270,当然你也可以根据需要继续扩大
#define _GAP 50000 // Minimum map between transmissions
默认的数据是5000,因为遥控器会连续发两段代码,所以5000这个参数不适用,需要改到50000,否则你只能
接受到前一段代码仍然无法控制你家的空调
// information for the interrupt handler
typedef struct {
uint8_t recvpin; // pin for IR data from detector
uint8_t rcvstate; // state machine
uint8_t blinkflag; // TRUE to enable blinking of pin 13 on IR processing
unsigned int timer; // state timer, counts 50uS ticks.
unsigned int rawbuf[RAWBUF]; // raw data
// uint8_t rawlen; // counter of entries in rawbuf
int rawlen;
}
irparams_t;
这段代码我们要修改的 rawlen的定义,在默认库中这个数据被定义为uint8 也就是 一个字节的整数,最大只能到255
所以我们将此参数改成int
==================================================================================================================================================================================================================================================
其中
设置 RAWBUF 500
设置 _GAP 50000
8900,4400,650,550,650,550,600,600,600,1650,650,550,650,550,600,600,600,600,550,1700,600,600,600,600,600,1650,600,600,600,600,550,600,600,600,600,600,600,600,600,550,600,600,600,600,600,1650,650,550,650,500,650,550,650,550,650,550,600,600,600,1700,550,600,600,1650,650,600,550,600,600,1700,600,600,550,19750,700,550,600,600,600,600,600,550,650,550,600,550,650,550,650,550,600,600,600,600,600,600,600,600,550,600,650,1600,700,550,550,600,600,600,600,550,650,550,650,550,650,550,650,550,600,600,600,600,600,550,650,550,600,550,650,550,600,1700,600,550,650,1650,650,1600,650,14982
8900,4400,650,600,600,550,650,550,600,600,600,600,600,600,600,600,550,600,600,1650,650,600,600,550,600,1700,600,550,600,600,600,600,600,600,600,600,600,550,600,600,600,600,600,600,600,1650,600,600,600,550,650,600,550,600,600,600,600,600,600,1650,600,600,600,1700,550,600,600,600,600,1700,550,600,600,19750,650,600,600,600,550,650,550,600,600,600,600,550,650,550,600,600,600,600,600,600,600,600,600,550,600,600,600,1650,650,550,600,600,600,600,600,600,600,600,550,600,600,600,600,550,650,600,550,600,600,600,600,550,650,600,600,600,550,1650,650,550,650,1650,600,600,600,27234