* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
* JVC and Panasonic protocol added by Kristian Lauszus (Thanks to zenwheel and other people at the original blog post)
*/
#include <IRremote.h>
int RECV_PIN = 11;//定义红外接收器的引脚为11
//unsigned int rawCodes_ac_close[264]={3288,1591,432,1186,432,372,444,383,433,375,443,1184,434,382,434,383,433,384,433,383,433,1187,432,382,433,1186,432,1185,432,382,434,1186,431,1187,432,1186,432,1186,432,1186,432,383,433,1185,432,383,434,383,433,1186,432,383,433,383,433,383,433,384,433,1186,432,1186,432,1186,432,1186,432,383,433,383,433,383,433,384,433,384,433,384,433,383,433,383,433,383,433,383,433,383,433,384,433,384,432,384,432,383,433,383,432,384,432,385,432,385,432,384,432,384,432,385,432,384,432,384,432,384,432,1187,431,384,433,384,432,1187,431,1186,431,1186,431,384,433,27841,3287,1590,432,1186,431,384,434,383,433,383,433,1185,434,375,441,383,433,383,434,383,432,1186,433,382,433,1187,431,1186,432,383,433,1187,431,1186,432,1186,431,1186,432,1186,432,382,432,1187,431,383,433,384,433,1187,432,383,434,383,433,384,433,384,433,384,433,384,433,384,433,384,433,1186,432,1186,431,1187,431,1186,432,383,433,384,433,382,433,1186,430,1188,431,384,433,383,433,384,432,384,432,385,432,384,433,384,432,384,432,384,432,384,432,384,432,385,431,384,432,384,432,385,432,384,432,1188,431,383,433,384,432,1187,431,384,432,384,433,384,432,27841};
//unsigned int rawCodes_ac_close[264]={3448,1668,453,1244,453,390,466,402,454,393,464,1242,455,400,455,401,454,402,454,402,454,1244,453,401,454,1244,453,1243,453,401,455,1243,452,1244,453,1243,453,1243,453,1243,453,402,454,1243,453,402,455,401,454,1244,453,401,454,402,454,401,454,402,454,1244,453,1244,453,1244,453,1243,453,401,454,402,454,402,454,403,454,402,454,402,454,402,454,402,454,402,454,402,454,402,454,402,454,403,453,402,453,402,454,402,453,403,453,403,452,403,453,403,453,402,453,403,453,403,453,403,453,403,453,1245,452,402,454,402,452,1245,452,1244,452,1244,452,402,454,29191,3446,1668,453,1244,452,402,455,402,454,402,454,1242,455,394,462,401,454,402,455,402,453,1244,454,401,454,1244,452,1244,453,401,454,1244,452,1243,453,1243,452,1244,453,1243,453,401,453,1245,452,402,454,402,454,1244,452,401,455,402,454,402,454,402,454,402,454,402,454,402,454,403,454,1244,453,1244,452,1245,452,1244,453,402,454,402,454,401,454,1244,451,1245,452,402,454,402,454,403,453,403,453,403,453,403,454,403,453,403,453,402,453,403,453,403,453,403,452,403,453,403,453,403,453,403,453,1245,452,402,454,402,453,1245,452,403,453,402,454,402,453,29191};
unsigned int rawCodes_ac_close[264]={1727,890,-445,65,-165,65,-50,600,-550,700,-1600,700,-1600,650,-1650,600,-650,550,-600,600,-1650,650,-550,650,-600,600,-1650,600,-550,650,-550,650,-550,650,-550,650,-550,650,-550,650,-550,650,-550,650,-550,600 ,-1650,650,-550,650,-550,650,-550,650,-550,650,-550,650,-550,650,-1600,700,-500,650,-1650,650,-550,650,-550,650,-1600,650,-550,650};
//上面改成你接受到的数据,请注意把接受到的第一个数据放到最后
IRrecv irrecv(RECV_PIN);
decode_results results;
IRsend irsend;
//test
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // 初始化红外接收器
}
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++) {
if ((i % 2) == 1) {
Serial.print(results->rawbuf[i]*USECPERTICK, DEC);
}
else {
Serial.print(-(int)results->rawbuf[i]*USECPERTICK, DEC);
}
Serial.print(" ");
}
Serial.println("");
}
void loop() {
irsend.sendRaw(rawCodes_ac_close,264, 40);
delay(5);
// irsend.sendRaw(rawCodes_ac_close,264, 40);
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
dump(&results);
// irsend.mark(560);
// irsend.space(560);
// irsend.mark(2000);
// irsend.space(560);
//rsend.sendRaw(rawCodes_ac_close,6, 32);
irrecv.resume(); // Receive the next value
}
delay(5000);
}
我用这个程序编程就出现这样子的问题
Arduino:1.7.3 (Windows 8.1), 板:"Arduino Uno"
IRrecvDump.ino:16:1: error: stray '\' in program
IRrecvDump.ino:16:1: error: stray '\' in program
IRrecvDump.ino:16:1: error: stray '\' in program
IRrecvDump.ino:16:1: error: stray '\' in program
IRrecvDump.ino:16:1: error: stray '\' in program
IRrecvDump.ino:16:1: error: stray '\' in program
IRrecvDump.ino:16:1: error: stray '\' in program
IRrecvDump.ino:16:1: error: stray '\' in program
IRrecvDump.ino:16:43: error: expected '}' before 'uff0c890'
IRrecvDump.ino:16:43: error: expected ',' or ';' before 'uff0c890'
IRrecvDump.ino:16:417: error: expected declaration before '}' token
编译有误。
报告将会包含更多的信息
"在编译时,输出详细信息"
在 文件>首选项 中启用
求大神帮我看看怎么了
|